2013-10-03 100 views
0


我想初始化一個簡單的JAX-WS Web服務,
當我初始化新的服務對象的異常被拋出時,面臨着一個問題:例如,新HelloService的()]
我試圖按照有關如何override endpoint address
我也發現了類似的問題上StackOverflow java.net上的說明,
但仍面臨着同樣的問題:覆蓋端點地址,WSDL扔InaccessibleWSDLException

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) 
+0

你能夠在瀏覽器中查看wsdl嗎? –

回答

3

我能夠解決這個問題。
以前,指令I用於生成客戶端是:

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

謝謝!