在JAX-WS中不是有效的服务异常 [英] Is not a valid service exception in JAX-WS
本文介绍了在JAX-WS中不是有效的服务异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在从 http://引用www.mkyong.com/webservices/jax-ws/jax-ws-hello-world-example/
这是我的 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"));
}
}
运行此类时,我从下面的代码行中获取错误
When running this class i am getting error from below line of code
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类的参考示例中,它具有
In the reference example in HelloWorldClient class it has
QName qname = new QName("http://ws.mkyong.com/", "HelloWorldImplService");
就我而言,我已将其替换为
In my case i have replaced it with
QName qname = new QName("http://localhost:8099/dummy1/dummy2?wsdl", "HelloWorldImplService");
我不知道我在哪里弄错了.当我跑步时
http://localhost:8099/dummy1/dummy2?wsdl
它工作正常.但是,当我从客户端访问时,我遇到了上述异常.请您提供任何帮助吗?
I could not figure out where i have made mistake .When i run
http://localhost:8099/dummy1/dummy2?wsdl
it is working fine.But ,when i access from client i am getting above mentioned exception.Any help please ?
推荐答案
尝试替换
QName qname = new QName("http://localhost:8099/dummy1/dummy2?wsdl", "HelloWorldImplService");
使用
QName qname = new QName("http://WebService/", "HelloWorldImplService");
这篇关于在JAX-WS中不是有效的服务异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文