Java 覆盖 JAX-WS WSDL 中的端点地址抛出 InaccessibleWSDLException

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19170152/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 14:42:17  来源:igfitidea点击:

overriding endpoint address in the JAX-WS WSDL throw InaccessibleWSDLException

javaweb-serviceswsdljax-ws

提问by JavaSheriff


I am facing an issue when trying to init a simple Jax-ws webservice,
the exception is thrown when I init the new service object: [e.g. new HelloService()]
I was trying to follow instructions on java.net on how to override endpoint address
I also found similar question on StackOverflow,
but still facing the same issue:


我在尝试初始化一个简单的 Jax-ws 网络服务时遇到了一个问题,
当我初始化新的服务对象时抛出异常:[例如 new HelloService()]
我试图按照 java.net 上关于如何覆盖端点的说明进行操作address
我也在StackOverflow上发现了类似的问题,
但仍然面临同样的问题:

com.sun.xml.internal.ws.wsdl.parser.InaccessibleWSDLException: 2 counts of InaccessibleWSDLException.
java.io.FileNotFoundException: http://server-ps:8080/halloWorld/HalloWorldWebService.wsdl
java.io.FileNotFoundException: http://server-ps:8080/halloWorld/HalloWorldWebService.wsdl?wsdl

Here is the code I am using (from the java.net article)

这是我正在使用的代码(来自 java.net 文章)

String halloServiceUrl = "http://server-ps:8080/halloWorld/HalloWorldWebService?wsdl";
HelloService service = new HelloService(); // I get the exception here..
HelloPort proxy =  service.getHelloPort(); 
    ((BindingProvider)proxy).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,alloServiceUrl);
proxy.sayHello("Hello World!");

full stack Trace:

全栈跟踪:

  com.sun.xml.internal.ws.wsdl.parser.InaccessibleWSDLException: 2 counts of InaccessibleWSDLException.

 java.io.FileNotFoundException: http://server-ps:8080/halloWorld/HalloWorldWebService.wsdl
 java.io.FileNotFoundException: http://server-ps:8080/halloWorld/HalloWorldWebService.wsdl?wsdl

 at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.tryWithMex(RuntimeWSDLParser.java:161)
 at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:133)
 at com.sun.xml.internal.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:254)
 at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:217)
 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 halloWorld.services.HalloWorldWebService_v1.HalloWorldWebService.<init>(HalloWorldWebService.java:46)
 at com.starOne.ps.cmmg.pkg.test.MiscTest.testhalloWorldServiceCall(MiscTest.java:73)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:597)
 at org.junit.runners.model.FrameworkMethod.runReflectiveCall(FrameworkMethod.java:47)
 at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
 at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
 at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
 at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
 at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
 at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
 at org.junit.runners.ParentRunner.run(ParentRunner.java:238)
 at org.junit.runners.ParentRunner.schedule(ParentRunner.java:63)
 at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
 at org.junit.runners.ParentRunner.access
wsimport -keep halloWorldWebService.wsdl -d output -s output -verbose
0(ParentRunner.java:53) at org.junit.runners.ParentRunner.evaluate(ParentRunner.java:229) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

采纳答案by JavaSheriff

I was able to work it out.
Previously the command I used to generate the clients was:

我能够解决它。
以前我用来生成客户端的命令是:

-wsdllocation http://localhost:8088/mockHWebServiceSOAP?WSDL


Once I added wsdllocation parameter to wsimport:


一旦我将 wsdllocation 参数添加到 wsimport:

String halloServiceUrl = "http://server-ps:8080/halloWorld/HalloWorldWebService";
HelloService service = new HelloService(); 
HelloPort proxy =  service.getHelloPort(); 
((BindingProvider)proxy).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,alloServiceUrl);
proxy.sayHello("Hello World!");


It is working as expected using the code:


它使用代码按预期工作:

##代码##

Thank you!

谢谢!