我面臨着同樣的問題,這是可怕的堂妹一旦代碼被移動到生產它總是尋找硬編碼的WSDL位置即Windows的C:........等
我有通過各種帖子和頁面找到答案,但都失敗了,然後通過查看由JAX-WS導入生成的服務類來發現自己。
我不得不像這樣在我的調用類中重寫JAX-WS WSDL位置實現。
URL baseUrl;
URL wsdlURL = null;
baseUrl = <your Services>.class.getResource(".");
try {
wsdlURL = new URL(baseUrl, "http://<your path>?wsdl");
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
<your Services> yourServices = new <your Services(wsdlURL,new QName("your namespace", "<your service name>"));
System.out.println(Services.getWSDLDocumentLocation());
YourInterface YourInterfacePort = yourServices.getServicePort();
BindingProvider bindingProvider = (BindingProvider)YourInterfacePort;
bindingProvider.getRequestContext().put(
BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);
YourInterfacePort.methods();
相關問題:http://stackoverflow.com/questions/3567856/changing-the-url-on-a-webservice-client-generated-with-wsimport – McDowell 2010-08-25 19:25:35