今天看了一下webService,写了一个测试,在测试的途中遇到一些问题。记录一下。。。
Service端的代码
package com.test.ws;
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService
public interface HelloWS {
@WebMethod
public String sayHello(String name);
}
package com.test.ws;
import javax.jws.WebService;
@WebService
public class HelloWSImp implements HelloWS{
@Override
public String sayHello(String name) {
System.out.println("HelloWS"+name);
return "Hello"+name;
}
}
package com.test.ws;
import javax.xml.ws.Endpoint;
public class publicService {
public static void main(String[] args) {
String address = "http://127.0.0.1:8080/test-webservice/hellows"; 就是下面的endPoint
Endpoint.publish(address, new HelloWSImp());
System.out.println("success!!!!");
}
}


结果报错了

后来才知道

call.setOperationName(new QName(endPointURL,serviceName));
endPointURL应该是nameSpace serviceName应该是name,方法名。


成功了!!!
本文分享了WebService从服务端接口定义到发布的过程,并解决了在部署过程中遇到的问题,包括正确设置endPointURL和服务名称。
1337

被折叠的 条评论
为什么被折叠?



