Topic
  • 4 replies
  • Latest Post - ‏2013-01-04T22:58:45Z by SystemAdmin
SystemAdmin
SystemAdmin
1250 Posts

Pinned topic Calling a Custom Salesforce.com API

‏2013-01-03T21:30:48Z |
Hi - I am brand new to Cast Iron and am having trouble calling a custom written Salesforce.com API in CI Studio.

I have a custom API that was written by one of my Salesforce developers to create new records or delete records, based on certain criteria that gets met on a related parent record.

I have downloaded the Enterprise WSDL from Salesforce, from there I am trying to invoke the login method before I call my custom API. From the documentation I have found thus far, it states that I must do this to get the sessionId for subsequent API calls.

I have also downloaded the WSDL for our custom API call. When I load the WSDL using the Invoke Service activity, the methods are available to me, but I am not sure how to pass the sessionID from the previous WSDL.
This webpage gives a broad overview of what we are trying to accomplish:
http://wiki.customware.net/repository/display/CASTIRON/How+to+call+Salesforce+API+directly

Any direction/knowledge/ advice on this is greatly appreciated!
Updated on 2013-01-04T22:58:45Z at 2013-01-04T22:58:45Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    1250 Posts

    Re: Calling a Custom Salesforce.com API

    ‏2013-01-03T21:46:06Z  
    On the Map Inputs panel of the Invoke Service activity (used to invoke the web service operation), right click in the area under "To Activity". A context menu will appear. Select "Show Optional Parameters". You should now see a headers document that allows you to populate the SOAP header defined for the web service operation (a subdocument should reference session information). (Optional parameters are also available for IP applications to support runtime configuration.)

    If your only reason for using the enterprise WSDL, consider the partner WSDL which is much more compact. You may also use one of the "light weight" activities associated with the Cast Iron built-in connector (e.g., get server timestamp or get user information) to establish a session. The outputs of all of the built-in connector activities include a sessionInfo document.
  • SystemAdmin
    SystemAdmin
    1250 Posts

    Re: Calling a Custom Salesforce.com API

    ‏2013-01-04T18:10:21Z  
    On the Map Inputs panel of the Invoke Service activity (used to invoke the web service operation), right click in the area under "To Activity". A context menu will appear. Select "Show Optional Parameters". You should now see a headers document that allows you to populate the SOAP header defined for the web service operation (a subdocument should reference session information). (Optional parameters are also available for IP applications to support runtime configuration.)

    If your only reason for using the enterprise WSDL, consider the partner WSDL which is much more compact. You may also use one of the "light weight" activities associated with the Cast Iron built-in connector (e.g., get server timestamp or get user information) to establish a session. The outputs of all of the built-in connector activities include a sessionInfo document.
    Thank you for the quick reply! That was a huge help!

    I was able to establish a session with Salesforce and login, but my problem now is passing the sessionId and the serverUrl to the web service I am trying to invoke.

    The error message I am getting is No operation available for request.

    I am not sure if this means the activity is able to connect to the web service, but not executing it, or if the web service was never connected to.
  • SystemAdmin
    SystemAdmin
    1250 Posts

    Re: Calling a Custom Salesforce.com API

    ‏2013-01-04T18:43:21Z  
    Thank you for the quick reply! That was a huge help!

    I was able to establish a session with Salesforce and login, but my problem now is passing the sessionId and the serverUrl to the web service I am trying to invoke.

    The error message I am getting is No operation available for request.

    I am not sure if this means the activity is able to connect to the web service, but not executing it, or if the web service was never connected to.
    Sounds like the URL you're passing to the optional "location" HTTP header isn't specifying the name of the Apex class in Salesforce that implements the custom Web service. If you parse the serverURL being returned from the login() call to Salesforce and replace everything following the "../Soap" portion of this URL with "/class/<Apex Class Name>", then Cast Iron should find it.

    For example, if you have an Apex class named "mySvc", the URL you pass to the location header in the Invoke Service activity may look something like: https://cs14-api.salesforce.com/services/Soap/class/mySvc.

    Hope this helps.

    -Paul
  • SystemAdmin
    SystemAdmin
    1250 Posts

    Re: Calling a Custom Salesforce.com API

    ‏2013-01-04T22:58:45Z  
    Sounds like the URL you're passing to the optional "location" HTTP header isn't specifying the name of the Apex class in Salesforce that implements the custom Web service. If you parse the serverURL being returned from the login() call to Salesforce and replace everything following the "../Soap" portion of this URL with "/class/<Apex Class Name>", then Cast Iron should find it.

    For example, if you have an Apex class named "mySvc", the URL you pass to the location header in the Invoke Service activity may look something like: https://cs14-api.salesforce.com/services/Soap/class/mySvc.

    Hope this helps.

    -Paul
    Wonderful! That worked perfect!

    Thank you all for your help!