我從http://www.mkyong.com/webservices/jax-ws/jax-ws-hello-world-example/是不是在JAX-WS有效的服務異常
採取參考這是我HelloWorldClient類
package WebService;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
public class HelloWorldClient{
public static void main(String[] args) throws Exception {
URL url = new URL("http://localhost:8099/dummy1/dummy2?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://localhost:8099/dummy1/dummy2?wsdl", "HelloWorldImplService");
Service service = Service.create(url, qname);
HelloWorld hello = service.getPort(HelloWorld.class);
System.out.println(hello.getHelloWorldAsString("mkyong"));
}
}
當運行這個類我從下面的代碼行收到錯誤
Service service = Service.create(url, qname);
的錯誤是
Exception in thread "main" javax.xml.ws.WebServiceException: {http://localhost:8099/dummy1/dummy2?wsdl}HelloWorldImplService is not a valid service. Valid services are: {http://WebService/}HelloWorldImplService
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:220)
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:165)
at com.sun.xml.internal.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:93)
at javax.xml.ws.Service.<init>(Service.java:56)
at javax.xml.ws.Service.create(Service.java:680)
at WebService.HelloWorldClient.main(HelloWorldClient.java:19)
在參考示例中HelloWorldClient類有
QName qname = new QName("http://ws.mkyong.com/", "HelloWorldImplService");
在我的情況我有
QName qname = new QName("http://localhost:8099/dummy1/dummy2?wsdl", "HelloWorldImplService");
取代它,我無法找出我在那裏犯的錯誤。當我運行 http://localhost:8099/dummy1/dummy2?wsdl
它工作的很好。但是,當我從客戶端訪問我得到上面提到的異常。請任何幫助嗎?
它已經在錯誤信息:'有效的服務宗旨是:{HTTP://的WebService /}' –