Many a times we define Apex Webservices inside Salesforce to perform operations on Salesforce data from external world. Anyhow always we are left on how to access these custom defined web services from a WSDL consumer (JAVA/ NET / …)
If we start consuming Parner WSDL only, then we do not get the apex webservice defintions. Partner WSDL doesn’t contain your custom defined webservice definitions. You’ll also have to cosume Apex Webservice WSDL to call your webservice.
So this involves following 2 steps …
- Step1 : Consume Partner WSDL and then perform Login call to SFDC
- Step2 : Consume Apex Webservice WSDL and Set above fetched SessionId as the sessionHeader on the Apex Webservice WSDL stub and then call the required methods.
binding1 = (SoapBindingStub) new SforceServiceLocator().getSoap();
loginResult = binding1.login(“username”,”PwdToken”);
SessionHeader sh = new SessionHeader();
sh.setSessionId(loginResult.getSessionId());
binding2 = (checkForLeadNumberBindingStub) new checkForLeadNumberServiceLocator().getcheckForLeadNumber();
binding2.setHeader(new checkForLeadNumberServiceLocator().getServiceName().getNamespaceURI(), “SessionHeader”, sh);
binding2.extractLeadId(“123456″,”123456”);
Recent Comments