您的位置:首页 > 编程语言 > Java开发

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

2017-02-22 09:20 309 查看
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,会出现如下信息:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: