Java 使用动态url的可移植JAXWS客户端web服务出错,仍在搜索本地wsdl
在阅读了这篇文章和其他许多文章之后 我有客户机wsdl,从中我生成了如下java存根:Java 使用动态url的可移植JAXWS客户端web服务出错,仍在搜索本地wsdl,java,client,jax-ws,Java,Client,Jax Ws,在阅读了这篇文章和其他许多文章之后 我有客户机wsdl,从中我生成了如下java存根: wsimport.bat -Xnocompile -keep -Xendorsed Client_aaa.wsdl 现在,在客户端中,我希望能够设置动态端点URL,在阅读了这里的几篇文章后,我是这样做的: responseUrl = "...each thread get different endpoint url ...." ApiService ApiService = new Api
wsimport.bat -Xnocompile -keep -Xendorsed Client_aaa.wsdl
现在,在客户端中,我希望能够设置动态端点URL,在阅读了这里的几篇文章后,我是这样做的:
responseUrl = "...each thread get different endpoint url ...."
ApiService ApiService = new ApiService();
Api port = ApiService.getApiPort();
int ws_request_timeout = 3000
int ws_connect_timeout = 3000;
try{
((BindingProvider)port).getRequestContext().put("com.sun.xml.internal.ws.request.timeout",ws_request_timeout);
((BindingProvider)port).getRequestContext().put("com.sun.xml.internal.ws.connect.timeout",ws_connect_timeout);
((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,responseUrl);
}
catch(ClassCastException cco)
{
cco.printStackTrace();
}
catch(UnsupportedOperationException uso)
{
uso.printStackTrace();
}
catch(Exception e)
{
e.printStackTrace();
}
PACK PACK = port.sendAPI(MESSAGE);
但当涉及到客户端的实际调用时,我得到了一个例外:
Exception in thread "pool-1-thread-20" javax.xml.ws.WebServiceException: Failed to access th
e WSDL at: file:/D:/Java_2/libs/JAXWS2.2.5-20110729/jaxws-ri/bin/Client_aaa.wsdl.
It failed with:
Got D:\Java_2\libs\JAXWS2.2.5-20110729\jaxws-ri\bin\Client_aaa.wsdl (The
device is not ready) while opening stream from file:/D:/Java_2/libs/JAXWS2.2.5-20110729/jaxws
-ri/bin/Client_aaa.wsdl.
at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.tryWithMex(RuntimeWSDLParser.java:188
)
at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:170)
at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:135)
at com.sun.xml.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:275)
at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:238)
at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:186)
at com.sun.xml.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:111)
at javax.xml.ws.Service.<init>(Service.java:56)
at il.co.np.ApiService.<init>(Unknown Source)
at com.serverrequest.RunnableTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886
)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
如何将其移除?或者更好的方法是,当我尝试使用动态endpoit调用时忽略它
@WebServiceClient(name = "ApiService", targetNamespace = "http://www.endpointurl/NP/2.0/", wsdlLocation = "file:/D:/Java_2/libs/JAXWS2.2.5-20110729/jaxws-ri/bin/Client_aaa.wsdl")