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
Vipul Sharma 15Vipul Sharma 15 

integrating salesforce to salesforce using SOAP Webservice

Hi Everyone , I am stuck
I am currently testing out some functionality where I have to pass 1 record value from one instance to other instance of salesforce using SOAP webservice and WSDL , steps being followed by me :
step1 :  wrote a webservice class in SFDC instance1
step2 : after successfull creation , clicked on GENERATE WSDL on the same page and saved it.
step 3 : opened my SFDC instance2 and in Apex class -- clicked on Generate from  WSDL , here i refered to the wsdl class which I had obtained from SFDC instance 1.
step 4 :  now I am working in my another controller class in sfdc Instance2 and trying to fetch the data retured from WSDL class (by intiating it and calling my method in it ) but it is saying
"System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session faultcode=sf:INVALID_SESSION_ID faultactor="

I know I am missing many things :
- call login() with username and password
- I have to fetch the session ID and use it

even I want to set them up , but I am unable to find out them in my "APEX generated from wsdl class" . There is only 1 method with the name LoginINFO (no username or password in the method) in my apex generated frm WSDL
please advise and assist me.
NagaNaga (Salesforce Developers) 
Hi Vipul,

I think you cannot get the session ID when running a batch:

Look up "getSessionId()" usage

Please let me know if this helps

Best Regards
Naga Kiran
Bhavdip P GadhiyaBhavdip P Gadhiya
Hello Everyone,

I followed steps to connect Salesforce to Salesforce using soap API and its working so it may be helped you.

Below the steps for salesforce to salesforce integration
1) Source Org. --> Generate the WSDL from Source Org.(org A) --> Setup --> API
there are the many options for WSDL files but we have to work on two WSDL
    i) Enterprise WSDL --> A strongly typed WSDL means that if you generated WSDL once then you created any custom object or field or related to any schema then target org(org. B) cannot be used those object and field. That's why it's also called static WSDL.
    ii) Partner WSDL --> A loosely typed WSDL means that if you generated WSDL once then you created any custom object or other then its accessible for target org(org. B). That's why its called dynamic WSDL.
2) Source Org. --> Create the Apex web service Class with 'global' class and method with 'web service' and 'static' so it can be identified web service class. You can write logic inside it.
3) Target org. -->  Setup --> Apex --> parse. Parse those two WSDL in your target org(org B) so generate the different class.
3) Target org.  --> Setup --> Remote Access setting --> create endpoint URL.
      - salesforce to salesforce, there are two endpoints URL. 
               i. for connection ex. you can find from WSDL to apex class.
               ii. for calling method that's also found from WSDL to apex class.
       - Salesforce to another system 
                i. generally, required only 1 endpoints URL and 1 WSDL file.
4) Target org. -->  now there are two steps for processing data
        - in the controller, call login method and also pass username, password and security token(Note: if IP restriction is there then you cannot find a token option.)
        - in return value of login method, you get session id and that you have to set in header element.
        - Once set the header, now you can call the source org web service method( the method which you created in source org). 
         - Using visualforce page, you insert or display data in target org from or to source org.

leela krishna 6leela krishna 6
Hi I'm getting following error . 
Apex Generation Failed
Unsupported schema type: {}anyType
dilip Jaindilip Jain

<element name="NewValue" nillable="true" minOccurs="0" type="xsd:anyType"/>
<element name="OldValue" nillable="true" minOccurs="0" type="xsd:anyType"/>

change the type="xsd:anyType" to type="xsd:string"

Convert the anyType into a string and you're good to go!
<element name="NewValue" nillable="true" minOccurs="0" type="xsd:string"/>
<element name="OldValue" nillable="true" minOccurs="0" type="xsd:string"/>