You need to sign in to do that
Don't have an account?
bdr_09
Java Client Code for Apex Web service Methods...
Hello All,
I have two apex web service methods and am unable to call these methods in java.
can any body suggest me how can use with java client program?
Thanks,
--bdr_09
I have two apex web service methods and am unable to call these methods in java.
can any body suggest me how can use with java client program?
Thanks,
--bdr_09
Hey guys,
I got the solution. It goes as follows ...
Step1 : Login to SFDC, using Enterprise/Partner WSDL and obtain SessionId
binding1 = (SoapBindingStub) new SforceServiceLocator().getSoap();
loginResult = binding1.login("username","PwdToken");
SessionHeader sh = new SessionHeader();
sh.setSessionId(loginResult.getSessionId());
Step2 : Set above fetched SessionId as the sessionHeader on your Apex Webservice WSDL stub and then call the required methods.
binding2 = (checkForLeadNumberBindingStub) new checkForLeadNumberServiceLocator().getcheckForLeadNumber();
binding2.setHeader(new checkForLeadNumberServiceLocator().getServiceName().getNamespaceURI(), "SessionHeader", sh);
binding2.extractLeadId("123456","123456");
So that's it, you are all done! nJoy!!
Note : binding1 and binding2 are pointers to Enterprise WSDL and Apex Webservice WSDL respectively.
private SoapBindingStub binding;
private checkForLeadNumberBindingStub binding2;
All Answers
hi Simon, I tried the same approach for calling the custom apex webservice from java. I created SessoinHeader from Enterprise.wsdl SforceServiceStub and tried to set it to SessionHeader object of my webservice. Please help me on this.
Thank You,
K. Mani Kumar.
Code for LOGIN call,
binding = (SoapBindingStub) new SforceServiceLocator().getSoap();
loginResult = binding.login("USERNAME","PWD");
SessionHeader sh = new SessionHeader();
sh.setSessionId(loginResult.getSessionId());
binding.setHeader(new SforceServiceLocator().getServiceName().getNamespaceURI(), "SessionHeader", sh);
Now Simon can you please help on how to use above generated session Id tand how to set it as the sessionHeader on your apex WS stub, call the methods.?
Hey guys,
I got the solution. It goes as follows ...
Step1 : Login to SFDC, using Enterprise/Partner WSDL and obtain SessionId
binding1 = (SoapBindingStub) new SforceServiceLocator().getSoap();
loginResult = binding1.login("username","PwdToken");
SessionHeader sh = new SessionHeader();
sh.setSessionId(loginResult.getSessionId());
Step2 : Set above fetched SessionId as the sessionHeader on your Apex Webservice WSDL stub and then call the required methods.
binding2 = (checkForLeadNumberBindingStub) new checkForLeadNumberServiceLocator().getcheckForLeadNumber();
binding2.setHeader(new checkForLeadNumberServiceLocator().getServiceName().getNamespaceURI(), "SessionHeader", sh);
binding2.extractLeadId("123456","123456");
So that's it, you are all done! nJoy!!
Note : binding1 and binding2 are pointers to Enterprise WSDL and Apex Webservice WSDL respectively.
private SoapBindingStub binding;
private checkForLeadNumberBindingStub binding2;
This is very useful info.
Question: Once you have established the two bindings, can you use binding1 to do "normal" non-Web Service calls, like binding1.create(Account) and binding2 to do Apex Web Service calls?
On a related topic, I'm getting the following errors when running two Java apps in the same web server using the same user and I'm caching the session info so I can re-use. Is this OK or should I use two separate users for each app? Thanks for any advice.
2011-12-20 14:46:00,833 ERROR [com.cort.sf.model.SfBase] - Failed to create Account succesfully, error message was:
Invalid Session ID found in SessionHeader: Illegal Session. Session not found, missing session key: 00D70000000J3Ew!AQYAQPsLcKyTqKTUnNftoABV1FZ857HiJWTRVVw_7Jtm1VfaQinx0TVBY771ut2yGgvJY6kMrTW.XEeQwMYizQ5JtKdzZBlU