public interface WeatherInterface {
//天气查询
public String queryWeather(String cityName);
}@WebService//@WebService表示该类是一个服务类需要发布其中的public方法
public class WeatherInterfaceImpl implements WeatherInterface {
public String queryWeather(String cityName) {
System.out.println("from client..."+cityName);
String weather = "晴";
System.out.println("to client..."+weather);
return weather;
}
}public class WeatherServer {
public static void main(String[] args) {
//Endpoint发布服务
//参数解释
//1.address - 服务地址
//2.implementor - 实现类
Endpoint.publish("http://localhost:8989/weather",new WeatherInterfaceImpl());
System.out.println("发布成功!");
}
}
执行代码显示发布成功后,浏览器端访问显示 错误码 324 (net::ERR_EMPTY_RESPONSE)。
地址写127.0.0.1,beiji ip都是一样的访问的结果,求解。
写的代码和范例一样,就是访问不出结果。
check一下
https://stackoverflow.com/questions/2083500/java-using-endpoint-to-publish-webservice-to-tomcat-server/2083707#2083707
试过了,显示This XML file does not appear to have any style information associated with it. The document tree is shown below.
看了下 这个是用tomcat容器的,有区别啊
jdk1.8.0_171检查一下你本地是否有对端口的屏蔽。或者换成8080或者80端口试一下。
This XML file does not appear to have any style information associated with it. The document tree is shown below.
但是这个下面显示正确的wsdl内容。
<xsd:import namespace="http://temp/" schemaLocation="http://localhost:8989/weather?xsd=1"></xsd:import>
我查一下,先看一下这个
https://stackoverflow.com/questions/21177387/caution-provisional-headers-are-shown-in-chrome-debugger
如果客户端调用没问题的话,应该是发布成功了。这个文章或许可以解决你的问题
https://stackoverflow.com/questions/20802335/endpoint-publish-for-rest-web-services
用jdk1.7.0_71可以https://bbs.csdn.net/topics/392406467