我是 jax-ws 的新手
我有以下界面
@WebService(name = "HelloWorld", targetNamespace = "http://pack/")
@SOAPBinding(style = SOAPBinding.Style.RPC)
public interface HelloWorld {
/**
*
* @param arg0
* @return
* returns java.lang.String
*/
@WebMethod
@WebResult(partName = "return")
public String getHelloWorldAsString(
@WebParam(name = "arg0", partName = "arg0")
String arg0);
}
以下实施
@WebService(endpointInterface = "pack.HelloWorld")
public class HelloWorldImpl implements HelloWorld{
@Override
public String getHelloWorldAsString(String name) {
return "Hello World JAX-WS " + name;
}
}
以下客户端代码:
public class HelloWorldClient{
public static void main(String[] args) throws Exception {
URL url = new URL("http://localhost:9999/ws/hello?wsdl");
//1st argument service URI, refer to wsdl document above
//2nd argument is service name, refer to wsdl document above
QName qname = new QName("http://pack/", "HelloWorldImplService");
Service service = Service.create(url, qname);
HelloWorld hello = service.getPort(HelloWorld.class);
System.out.println(hello.getHelloWorldAsString("mkyong"));
}
}
在控制台中我看到
Hello World JAX-WS mkyong
TCP/IP 监视器:
我这样配置它:
为什么我在 TCP/IP 监视器上看不到消息?
更新皮尼奇
如果我输入相同的本地监控端口和端口(确定按钮已禁用),我会看到下一个:
更新 2
在那之后
我看到旧的行为
出版商
我忘记为发布者添加代码:
public class HelloWorldPublisher{
public static void main(String[] args) {
Endpoint.publish("http://localhost:9999/ws/hello", new HelloWorldImpl());
}