+ Start a Discussion
RichardQRichardQ 

What should the SOAP message look like for a simple create a lead?

Hi.

 

I've just started with the SalesForce SOAP service using PHP. I have a WSDL2PHP translation tool which produces a set of classes (structures and service layer) and this has always worked for the simpler services (and not so simple) I've needed to interact with.

 

What I'm having trouble with is arrays in SOAP.

 

My request currently looks like this.

 

<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
                   xmlns:ns1="urn:enterprise.soap.sforce.com"
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <SOAP-ENV:Header>
        <ns1:SessionHeader>
            <ns1:sessionId>**************************************</ns1:sessionId>
        </ns1:SessionHeader>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
        <ns1:create>
            <ns1:sObjects>
                <Lead xsi:type="ns1:Lead">
                    <AcceptedEventRelations />
                    <ActivityHistories />
                    <AnnualRevenue />
                    <AttachedContentDocuments />
...
                    <UndecidedEventRelations />
                    <Website />
                    <fieldsToNull />
                    <Id />
                    <type>Lead</type>
                </Lead>
                <ns1:Lead xsi:type="ns1:Lead">
                    <AcceptedEventRelations />
                    <ActivityHistories />
                    <AnnualRevenue />
                    <AttachedContentDocuments />
...
                    <UndecidedEventRelations />
                    <Website />
                    <fieldsToNull />
                    <Id />
                    <type>Lead</type>
                </ns1:Lead>
            </ns1:sObjects>
        </ns1:create>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

 

But I'm getting an error.

 

<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                  xmlns:sf="urn:fault.enterprise.soap.sforce.com"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body>
        <soapenv:Fault>
            <faultcode>sf:INVALID_TYPE</faultcode>
            <faultstring>INVALID_TYPE: Must send a concrete entity type.</faultstring>
            <detail>
                <sf:InvalidSObjectFault xsi:type="sf:InvalidSObjectFault">
                    <sf:exceptionCode>INVALID_TYPE</sf:exceptionCode>
                    <sf:exceptionMessage>Must send a concrete entity type.</sf:exceptionMessage>
                    <sf:row>-1</sf:row>
                    <sf:column>-1</sf:column>
                </sf:InvalidSObjectFault>
            </detail>
        </soapenv:Fault>
    </soapenv:Body>
</soapenv:Envelope>

 

I'm not a SOAP expert, so I'm probably missing something REALLY obvious.

 

Once I can work out what I'm supposed to create, I can then use that as a pattern for all of the arrays.

 

Is the expected to route to always use stdClass and then cast them via SOAPVar/SOAPParam?

 

Anything useful would be appreciated.

 

Regards,

 

Richard.

Best Answer chosen by Admin (Salesforce Developers) 
RichardQRichardQ

Found some examples and finally got an array of leads passed through to the service and a response (the response is permission related, so I assume things are working well enough at this stage).

 

For the record, this is what I have that is working.

 

<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xmlns:ns1="urn:sobject.enterprise.soap.sforce.com"
                   xmlns:ns2="urn:enterprise.soap.sforce.com">
    <SOAP-ENV:Header>
        <ns2:SessionHeader>
            <ns2:sessionId>***************************</ns2:sessionId>
        </ns2:SessionHeader>
    </SOAP-ENV:Header>
    <SOAP-ENV:Body>
        <ns2:create>
            <ns2:sObjects xsi:type="ns1:Lead">
                <ns1:fieldsToNull xsi:nil="true" />
                <ns1:Id xsi:nil="true" />
                <ns1:AcceptedEventRelations xsi:nil="true" />
...
                <ns1:Tasks xsi:nil="true" />
                <ns1:Title xsi:nil="true" />
                <ns1:UndecidedEventRelations xsi:nil="true" />
                <ns1:Website xsi:nil="true" />
            </ns2:sObjects>
            <ns2:sObjects xsi:type="ns1:Lead">
                <ns1:fieldsToNull xsi:nil="true" />
                <ns1:Id xsi:nil="true" />
                <ns1:AcceptedEventRelations xsi:nil="true" />
...
                <ns1:Tasks xsi:nil="true" />
                <ns1:Title xsi:nil="true" />
                <ns1:UndecidedEventRelations xsi:nil="true" />
                <ns1:Website xsi:nil="true" />
            </ns2:sObjects>
        </ns2:create>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

 

Thanks for those that looked.

 

Regards,

 

Richard.