0


我在尝试初始化一个简单的 Jax-ws webservice 时遇到了一个问题,
当我初始化新的服务对象时抛出异常:[例如 new HelloService()]
我试图按照 java.net 上关于如何覆盖端点的说明进行操作地址
我也在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

这是我正在使用的代码(来自 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!");

全栈跟踪:

  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$1.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$3.run(ParentRunner.java:238)
 at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
 at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
 at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
 at org.junit.runners.ParentRunner$2.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)
4

1 回答 1

3

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

wsimport -keep halloWorldWebService.wsdl -d output -s output -verbose


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

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


它使用以下代码按预期工作:

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!");

谢谢!

于 2013-10-07T14:26:54.143 回答