+ Start a Discussion
SFDC coderSFDC coder 

Enterprise wsdl SOAP request for upsert.Am i on right track?

hi all,

i am trying to execute upsert call from enterprise wsdl via SOAP UI tool
below is my soap request.

Problem: i am unable to specify the object type.
 
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:urn="urn:enterprise.soap.sforce.com" 
xmlns:urn1="urn:sobject.enterprise.soap.sforce.com">
   <soapenv:Header>
     
      <urn:SessionHeader>
         <urn:sessionId>XXXXXXXXXXXXXXX</urn:sessionId>
      </urn:SessionHeader>
   </soapenv:Header>
   <soapenv:Body>
      <urn:upsert>
         <urn:externalIDFieldName>Product_Id__c</urn:externalIDFieldName>
         <!--Zero or more repetitions:-->
         <urn:sObjects urn:type="Product__c">
            <!--Zero or more repetitions:-->
          <Product_Id__c>456721</Product_Id__c>
          <Name>My test</Name>
          <Product_Brand__c>HIGHLAND PARK</Product_Brand__c>
         </urn:sObjects>
      </urn:upsert>
   </soapenv:Body>
</soapenv:Envelope>
When i run this request i get the below response
 
<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 then added the namespace to my request 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 and the upsert was successfull.Is this a correct way to add the namespace explicitly?
If i send such a wsdl to third party it would eventually fail 
Best Answer chosen by SFDC coder
Sumitkumar_ShingaviSumitkumar_Shingavi
Are you passing valid Session Id in <urn:sessionId>XXXXXXXXXXXXXXX</urn:sessionId> ?

To get session id; you can do below in debug log
System.debug(LoggingLevel.INFO, '==Session Id=='+Userinfo.getSessionId());
Then pickup this Session Id value and put it in your request and you should see Success!

PS: if this answers your question then hit Like and mark it as solution!

All Answers

Sumitkumar_ShingaviSumitkumar_Shingavi
Are you passing valid Session Id in <urn:sessionId>XXXXXXXXXXXXXXX</urn:sessionId> ?

To get session id; you can do below in debug log
System.debug(LoggingLevel.INFO, '==Session Id=='+Userinfo.getSessionId());
Then pickup this Session Id value and put it in your request and you should see Success!

PS: if this answers your question then hit Like and mark it as solution!
This was selected as the best answer
Sumitkumar_ShingaviSumitkumar_Shingavi
I correct, "you can do below in debug log " => "you can do below in developer console "
SFDC coderSFDC coder
yes its working fine  now..Also i tried to execute delete call via SOAP UI for enterprise WSDL.
However i see that we need to pass record id for deletion.Can we pass external id instead of record id?Is that possible?
if yes then what do i modify in the below delete soap request?

 
soapenv:Envelope xmlns:soapenv="<a rel="nofollow" class="external free" href="http://schemas.xmlsoap.org/soap/envelope/">http://schemas.xmlsoap.org/soap/envelope/</a>"
  xmlns:urn="urn:enterprise.soap.sforce.com">

  <soapenv:Header>
     <urn:SessionHeader>
        <urn:sessionId><b>QwWsHJyTPW.1pd0_jXlNKOSU</b></urn:sessionId>
     </urn:SessionHeader>
  </soapenv:Header>
  <soapenv:Body>
     <urn:delete>
        <!--Zero or more repetitions:-->
        <urn:ids>003D000000OXWBg</urn:ids> //Instead of this i want to pass external Id
     </urn:delete>
  </soapenv:Body>

</soapenv:Envelope>

 
Sumitkumar_ShingaviSumitkumar_Shingavi
I think Delete might work with External Id also as they are always indexed and unique.

Can you try below as body? So your SOAP body will look like below:
<soapenv:Body>
      <urn:delete>
         <urn:externalIDFieldName>Product_Id__c</urn:externalIDFieldName>
         <!--Zero or more repetitions:-->
         <urn:sObjects urn:type="Product__c">
          <Product_Id__c>456721</Product_Id__c>
         </urn:sObjects>
      </urn:delete>
   </soapenv:Body>
It would be great to start a new thread for any new discussions rather than mixing all stuff at one place so that other people get advantage out of it. Hence, it will be great if you mark my previous response as answer and start new discussion for new question. I will definately help you wherever you need me.

PS: if this answers your question then hit Like and mark it as solution!
SFDC coderSFDC coder
apologies for mixing the discussion.I have now created a new thread for my another question
https://developer.salesforce.com/forums/ForumsMain?id=906F0000000AnpsIAC

thanks
 
amidstcloudamidstcloud
Hi Sumit. 
I am facing a issue similar to this . I would like to upsert the records with the external Id in the lookup object. Let's take an example of account and contact. I would like to make a upsert call in contact object, and below is the code.  Here , external Id is for the account , so i don't need to pass SFDC account ID in the request.

Error : 

INVALID_TYPE Must send a concrete entity type. -1 -1

 
<urn:upsert>
        <urn:externalIDFieldName>Account.Partner_Number_HDS__c</urn:externalIDFieldName>
            <urn:sObjects xsi:type="urn1:Contact"> <!--Zero or more repetitions:--> 
             <FirstName>EnterA</FirstName>
              <LastName>EnterB</LastName>
            <Department>Sales</Department>
            <Job_Title_HDS__c>Account Manager</Job_Title_HDS__c>
            <MobilePhone>456768985</MobilePhone>
            <Email>test@test.com</Email>
            <Account.Partner_Number_HDS__c>PA-74</Account.Partner_Number_HDS__c>   
</urn:sObjects>
</urn:upsert>