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
forcerocksforcerocks 

Calling Apex Web Service in one Org from Apex Callouts in another

Hello,

 

I was trying to perform a quick test on my Apex Web Service (Apex method with webservice annotation).

The online help on using web service WSDLs in Apex callouts mentions that 'only one loopback connection to Salesforce domain is allowed.' So I guess I should be able to use Apex callout feature to test this Apex web service hosted in same org i.e. loopback test. Further, I guess should be able to make an Apex callout to another Apex Web Service in another org.

 

Question is: how do I connect to same/another Salesforce org using Apex callout? In other words, what's the equivalent in Apex of login() call in Web Services API that returns session Id to be used in subsequent calls? 

 

Since my Apex Web Service and Apex client (generated from the WSDL of Apex web service) are in same org, I tried using current session id to connect to this service, but it failed with SOAP fault INVALID_SESSIONID.

 

How do I obtain correct session id using Apex?

 

Although Salesforce-to-Salesforce feature can be used to access Salesforce data from another org, I can see legitimate use cases where a web service hosted in one org needs to be accessed from another org.

 

Any tips, hints, code snippets would be highly appreciated.

 

Thanks.

JPClark3JPClark3

I would also like to know if this is possible. Were you ever able to get this to work from one ORG to another?

 

Jeff

SubashKumarSubashKumar

Hi Clark,

 

Did you get any idea on doing this? I am badly in nned of doing such an implementation. Please share some info if you could do this.

 

Thanks,

Subash