gpt4 book ai didi

java - 不是 JAX-WS 中的有效服务异常

转载 作者:行者123 更新时间:2023-12-02 22:27:13 26 4
gpt4 key购买 nike

我正在引用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"));

}

}

运行此类时,我从下面的代码行收到错误

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 它工作正常。但是,当我从客户端访问时,我遇到了上述异常。请问有什么帮助吗?

最佳答案

尝试替换

QName qname = new QName("http://localhost:8099/dummy1/dummy2?wsdl", "HelloWorldImplService");

QName qname = new QName("http://WebService/", "HelloWorldImplService");

关于java - 不是 JAX-WS 中的有效服务异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19533904/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com