+ Start a Discussion
jkyrohonkajkyrohonka 

Problem with the insert method

Hi,

I was unable to express myself more concise, sorry.

Does anyone know if there is a problem with the following soap envelope.
I am trying to do an insert call.
The session id removed for clarity.

<?xml version="1.1" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
  xmlns:xsd="http://www.w3.org/1999/XMLSchema"
  xmlns:tns="salesforce"
  xmlns:SOAP-ENC="http://www.schemas.xmlsoap.org/soap/encoding">
 <soap:Header>
  <tns:headerStruct>
   <session_id xsi:type='xsd:string'> . . . </session_id>
   <version xsi:type='xsd:string'>2.0</version>
  </tns:headerStruct>
 </soap:Header>
 <s:Body>
  <m:insert xmlns:m='sfconnector:SalesforceConnector'>
   <type xsi:type='xsd:string'>account</type>
   <record xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="tns:mapEntry[1]">
    <value xsi:type='tns:mapEntry'>
     <key xsi:type='xsd:string'>name</key>
     <value xsi:type='xsd:string'>fredin akkountti 54321</value>
    </value>
   </record>
  </m:insert>
 </s:Body>
</s:Envelope>

Sending it gives a fault. Faultcode 1101, record field must be struct.

The next thing I tried was to use the format in the SOAP examples, that is

<?xml version="1.1" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
  xmlns:xsd="http://www.w3.org/1999/XMLSchema"
  xmlns:SOAP-ENC="http://www.schemas.xmlsoap.org/soap/encoding">

 <soap:Header>
  <tns:headerStruct>
   <session_id xsi:type='xsd:string'> . . . </session_id>
   <version xsi:type='xsd:string'>2.0</version>
  </tns:headerStruct>
 </soap:Header>

 <s:Body>
  <q1:insert xmlns:q1="sfconnector:SalesforceConnector">
    <type xsi:type="xsd:string">account</type>
    <record href="#id1" />
  </q1:insert>
  <soapenc:Array id="id1" soapenc:arrayType="tns:mapEntry[1]">
    <Item href="#id2" />
  </soapenc:Array>
  <tns:mapEntry id="id2" xsi:type="tns:mapEntry">
    <key xsi:type="xsd:string">name</key>
    <value xsi:type="xsd:string">fredin akkountti 54321</value>
  </tns:mapEntry>
 </s:Body>
</s:Envelope>

the response is the same.

Does it make a difference if the parts of the record parameter are
included through reference?

Also, if the envelope below would be collapsed in to a structure with
no references, would it look like:

  <q1:insert xmlns:q1="sfconnector:SalesforceConnector">
    <type xsi:type="xsd:string">account</type>
    <record xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="tns:mapEntry[1]"/>
     <Item xsi:type="tns:mapEntry">
      <key xsi:type="xsd:string">name</key>
      <value xsi:type="xsd:string">fredin akkountti 54321</value>
     </Item>
    </record>
  </q1:insert>

If so, isn't it said in the WSDL that the name of the elements inside a Map is 'value'?

I was just wondering if this could have anything to do with the error on the struct.

<xsd:complexType name="map">
 <xsd:complexContent>
  <xsd:restriction base="SOAP-ENC:Array">
   <xsd:sequence>
    <xsd:element maxOccurs="unbounded" minOccurs="0" name="value"
                 type="tns:mapEntry"/>                  // ^^^^^^ NAME
   </xsd:sequence>
   <xsd:attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="tns:mapEntry[]"/>
  </xsd:restriction>
 </xsd:complexContent>
</xsd:complexType>


And more. Doesn't a map traditionally map keys to values (as the complex type mapEntry is
defined in the WSDL)? However, e.g. the loginresponse has a map with three items: server_url,
session_id and user_id inside valueMap tags of type "map". (This isn't 'tns:map' map for the
map defined in the WSDL, is it?)

I hope I made my point..

thanks

 - Jussi

 

DevAngelDevAngel

Hi jkyrohonka,

First to the map issue on the response.  You are correct, if you take the wsdl literally (and why wouldn't you) the returned values should be in a map (array of mapEntrys).  You can get this behavior if you use 2.1 as the version.  This version is a dot release as it adds no new functionality over 2.0.  The only difference is the packaging of the response to conform to the letter of the wsdl.

Now for you soap envelope.  It seems that you are using a namespace reference "soap" for the header that is not defined.  I don't think this is a problem, but it is inconsistant. 

The real problem is with the encoding namespace.  You have used xmlns:SOAP-ENC='http://www.schemas.xmlsoap.org/soap/encoding'.  There are 2 problems with this.  The url does not point to anything.  You can check this by entering the url in a browser.  If you remove the www to make that line read xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding' you will have the correct url.   Again, you can see this by entering the url in your browser.  Finally, it seems that to have the service properly understand that url, you will need to add a "/" to the url ending up with xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/'.  If you use this you should be able to successfully execute your call.

Cheers

fouloxfoulox
Where release notes for the 2.1 release?
DevAngelDevAngel

Hi Lou,

No release notes are available for 2.1.  Again, 2.1 does not provide new functionality, it only returns the xml payload in a different format.

jkyrohonkajkyrohonka

Hi, and thanks for the answer. I appreciate the help. I guess all that soap is getting quite slippery by now...

I wonder how long it would have taken to see that embarassing blunder by myself.

One more thing about the WSDL, about the names of the elements of the structures (array, map). The sample for e.g.  the insert request has an <Item> tag that has the reference to a mapEntry element. In the 'record' parameter, that is.

Does the name of the tag have real meaning? The WSDL has 'value' as the name of an element of an array or map.

 

Thanks again!

-Jussi

DevAngelDevAngel

Hi jkyrohonka,

I don't think you would get in trouble using either one, but I would go with Item in creating your soap messages.