1
votes

I am new in SOAP Web service. I want to synch two Salesforce instance. For this I am using Partner WSDL. I have installed this WSDL into my instance and I have created one custom class:

public with sharing class ConnectionManager {
private String uName = 'xxx';
private String Password = 'xxx';
private partnerSoapSforceCom.Soap connection{get;set;}
public ConnectionManager() {
    connection = new partnerSoapSforceCom.Soap();
    partnerSoapSforceCom.LoginResult status = connection.login(uName, Password);
    system.debug('status: '+status);

    connection.endpoint_x = status.serverUrl;
    connection.SessionHeader = new partnerSoapSforceCom.SessionHeader_element();
    connection.SessionHeader.sessionId = status.sessionId;
    system.debug('connection.outputHttpHeaders_x: '+connection.outputHttpHeaders_x);

    //connection.inputHttpHeaders_x.put('Cookie',connection.outputHttpHeaders_x.get('Set-Cookie'));
    system.debug('qr: '+connection.query('SELECT Id, Name FROM Account where Name=\'test\''));
}}

But It is giving me one exception:

System.CalloutException: Web service callout failed: Unable to parse callout response. Apex type not found for element Name

Class.partnerSoapSforceCom.Soap.query: line 2048, column 1 Class.ConnectionManager.: line 16, column 1

it is logging into salesforce but giving me error in "connection.query()" method.

I checked in debug log and got this response xml:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:partner.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sf="urn:sobject.partner.soap.sforce.com">
    <soapenv:Header>
        <LimitInfoHeader>
            <limitInfo>
                <current>1</current>
                <limit>5000</limit>
                <type>API REQUESTS</type>
            </limitInfo>
        </LimitInfoHeader>
    </soapenv:Header>
    <soapenv:Body>
        <queryResponse>
            <result xsi:type="QueryResult">
                <done>true</done>
                <queryLocator xsi:nil="true"/>
                <records xsi:type="sf:sObject">
                    <sf:type>Account</sf:type>
                    <sf:Id>0019000000lhRWKAA2</sf:Id>
                    <sf:Id>0019000000lhRWKAA2</sf:Id>
                    <sf:Name>test</sf:Name>
                </records>
                <size>1</size>
            </result>
        </queryResponse>
    </soapenv:Body>
</soapenv:Envelope>

Please help me. Thanks in advance.

1

1 Answers

2
votes

It sounds like wsdl2apex didn't successfully create an Apex class to call the Partner WSDL of another ORG.

The Enterprise and Partner APIs are intended for usage outside of Salesforce rather than integrating two Salesforce Orgs together. They are typically consumed by languages like Java, .NET, PHP, Ruby, ...

You will probably be better off using Salesforce to Salesforce to share data between the two orgs.