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
Nick SFDCNick SFDC 

How to get custom auto number as response in Create SOAP API BULK request ?

Is there any way to get the custom auto-number as response form a Bulk create contact soap request without making another API call for a SOQL query?

Eg: Sample Create Bulk Request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com">
   <soapenv:Header>
      <urn:SessionHeader>
         <urn:sessionId>${SessionID}</urn:sessionId>
      </urn:SessionHeader>
   </soapenv:Header>
   <soapenv:Body>
      <urn:create>
       <urn:sObjects xsi:type="urn1:Contact" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
            <Salutation xsi:nil="false">Mr.</Salutation>
            <FirstName xsi:nil="false">David</FirstName>
            <LastName xsi:nil="false">McCall</LastName>
       </urn:sObjects>
        <urn:sObjects xsi:type="urn1:Contact" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
            <Salutation xsi:nil="false">Ms.</Salutation>
            <FirstName xsi:nil="false">Laura</FirstName>
            <LastName xsi:nil="false">McCall</LastName>
       </urn:sObjects>
      </urn:create>
   </soapenv:Body>
</soapenv:Envelope>



Response:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:enterprise.soap.sforce.com">
   <soapenv:Header>
      <LimitInfoHeader>
         <limitInfo>
            <current>114</current>
            <limit>5000000</limit>
            <type>API REQUESTS</type>
         </limitInfo>
      </LimitInfoHeader>
   </soapenv:Header>
   <soapenv:Body>
      <createResponse>
         <result>
            <id>003c0000000000000V</id>
            <success>true</success>
         </result>
         <result>
            <id>003c0000000000000V</id>
            <success>true</success>
         </result>
      </createResponse>
   </soapenv:Body>
</soapenv:Envelope>
I know we can create custom Apex SOAP webservice to get the auto-number as response but, in that I am able to insert only one record per request.
I need to resolve it in SOAP call..
Apex SOAP webservice 
global class contactCreate {
  webservice static Return Post(String FirstName, String LastName) {
        List<Contact> contList = new List<Contact>();  
        Contact Cont = new Contact(
                                    FirstName     = FirstName, 
                                    LastName     = LastName
                                   );
        contList.add(Cont);               
        try{
              insert conL;
              List<Contact> con    = [SELECT Id, SFContactId__c
                                                      FROM Contact
                                                   WHERE Id IN:conL];
              return new Return('TRUE',' Created Successfully.', con);
            }catch (Exception e)  {
              return new Return('FALSE',e.getMessage(), NULL); } 
    }
}
Raj VakatiRaj Vakati
try like this
 
global class contactCreate {
  webservice static Return Post(String FirstName, String LastName) {
        List<Contact> contList = new List<Contact>();  
        Contact Cont = new Contact(
                                    FirstName     = FirstName, 
                                    LastName     = LastName
                                   );
        contList.add(Cont);               
        try{
              insert conL;
              List<Contact> con    = [SELECT Id, SFContactId__c ,Name 
                                                      FROM Contact
                                                   WHERE Id IN:conL];
              return new Return('TRUE',' Created Successfully.', conL[0].Name);
            }catch (Exception e)  {
              return new Return('FALSE',e.getMessage(), NULL); } 
    }
	
	
 global class Return {

 
	webservice String status;

	webservice String message;

     webservice String Name;

   }
}

 
Nick SFDCNick SFDC
Hi Raj,
Thank you for responding!
I have my return class someting like below..
global class Return {
        webservice String status;
        webservice String msg;
        webservice List<Contact> cons;

        global Return(String status, String msg, List<Contact> cons) {
              this.status = status;
              this.msg = msg;
              this.cons = cons;
        }
and I'm able to get the auto-number as response but using the above soap webservice I'm able to insert only one record at a time..below is the xml I got after importing wsdl onto SoapUI. When I try to insert more than 1 record it's throwing an error "one operation at one request"... How to make above apex soap webservice to insert more than one record in one request and fetch autonumbers for all those records as response
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cre="http://soap.sforce.com/schemas/class/ <classname>">
   <soapenv:Header>
      <con:SessionHeader>
         <con:sessionId>----sessionId----</cre:sessionId>
      </con:SessionHeader>
   </soapenv:Header>
   <soapenv:Body>
      <con:Post>
         <con:FirstName>David</cre:FirstName>
         <con:LastName>McCall</cre:LastName>
      </con:Post>
      <con:Post>
         <con:FirstName>Laura</cre:FirstName>
         <con:LastName>McCall</cre:LastName>
      </con:Post>
   </soapenv:Body>
</soapenv:Envelope>
Response:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <soapenv:Fault>
         <faultcode>soapenv:Client</faultcode>
         <faultstring>Only one operation within the same request is allowed.</faultstring>
      </soapenv:Fault>
   </soapenv:Body>
</soapenv:Envelope>