function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
vs94063vs94063 

How to Specify Port Address during login (JAX-WS Web Service Client)

Hi,
 I have downloaded the partner WSDL of the latest API version 14 and used JAX-WS wsimport tool (in ant build script) to generate the artifacts/classes.
In the web service client, during the login call, how can i specify/override the "port address URL"? I know that the WSDL contains the default port as:
Code:
<soap:address location="https://www.salesforce.com/services/Soap/u/14.0"/>

 


If i use Axis's WSDL2Java to generate the classes, the generated classes include "SfServiceLocator" class which has "getSoap(URL portAddress)" method through which i can specify/override the port address URL.
But the classes generated using JAX-WS wsimport doesn't contain the "SfServiceLocator" class. How can we get the equivalent of SfServiceLocator#getSoap(URL) in JAX-WS web service client?

Thank you.
vs94063vs94063
I found out the answer to this question. Here is the code that will also set the endpoint (port address):

Code:
//wsdl file location
URL wsdlLocation = this.getClass().getClassLoader().getResource("WEB-INF/partner.wsdl"); Soap port = new SforceService(wsdlLocation, new QName("urn:partner.soap.sforce.com", "SforceService")).getSoap(); BindingProvider bindingProvider = ((BindingProvider) port); Map<String, Object> reqCtx = bindingProvider.getRequestContext(); //set endpoint URL (port address) reqCtx.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "https://test.salesforce.com/services/Soap/u/14.0"); LoginResult loginResponse = port.login(username, password);