Java 基于web service 暴露接口 供外部调用


package cn.zr.out.outinterface;

import java.text.SimpleDateFormat;
import java.util.Date;

import javax.jws.WebService;
import javax.xml.ws.Endpoint;




@WebService(name="webSer",serviceName="userWebService",targetNamespace="outws")
public class OutInterface {

    public static void main(String[] args) {
        Endpoint.publish("http://localhost:9865/", new OutInterface());
        System.out.println("=== 程序正在运行 ===");
    }
    
    public String outService(String info) {
        String msg = "暴露接口"+info;
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        String currentTime = format.format(new Date());
        System.out.println(msg+",调用时间:"+currentTime);
        return msg;
    }
}

然后在浏览器上输入http://localhost:9865/webSer?wsdl,会出现如下信息:

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM