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
scoopscoop 

Query returns unexpected results

Hi,

I'm getting return values from a query about users but am getting some unexected results, namely every element is preceded by "nsX:"  is there a way to just get

<records>
    <username>
    <etc>
</records>

for each returned record as opposed to having the "nsX" added?

I'm sending:

<?xml version="1.0"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/
XMLSchema-instance">
 <soapenv:Header>
  <ns1:SessionHeader soapenv:mustUnderstand="0" xmlns:ns1="SoapService">
   <ns2:sessionId xmlns:ns2="urn:enterprise.soap.sforce.com">[omit]</ns2:sessionId>
  </ns1:SessionHeader>
  <ns3:QueryOptions soapenv:mustUnderstand="0" xmlns:ns3="SoapService">
   <ns4:batchSize xmlns:ns4="urn:enterprise.soap.sforce.com">100</ns4:batchSize>
  </ns3:QueryOptions>
 </soapenv:Header>
 <soapenv:Body>
  <query xmlns="urn:enterprise.soap.sforce.com">
   <queryString>select username, firstName, lastName, id from User</queryString>
  </query>
 </soapenv:Body>
</soapenv:Envelope>

and receiving

<?xml version="1.0"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <soapenv:Body>
  <queryResponse xmlns="urn:enterprise.soap.sforce.com">
   <result>
    <done>true</done>
    <queryLocator xsi:nil="true"/>
    <records>
     <ns1:type xmlns:ns1="urn:sobject.partner.soap.sforce.com">User</ns1:type>
     <ns2:Username xmlns:ns2="urn:sobject.partner.soap.sforce.com">greg@insidescoop.com</ns2:Username>
     <ns3:FirstName xmlns:ns3="urn:sobject.partner.soap.sforce.com">Greg</ns3:FirstName>
     <ns4:LastName xmlns:ns4="urn:sobject.partner.soap.sforce.com">Campbell</ns4:LastName>
     <ns5:Id xmlns:ns5="urn:sobject.partner.soap.sforce.com">00530000000byXhAAI</ns5:Id>
    </records>
    <records>
     <ns6:type xmlns:ns6="urn:sobject.partner.soap.sforce.com">User</ns6:type>
     <ns7:Username xmlns:ns7="urn:sobject.partner.soap.sforce.com">cbadger@insidescoop.com</ns7:Username>
     <ns8:FirstName xmlns:ns8="urn:sobject.partner.soap.sforce.com">Chris</ns8:FirstName>
     <ns9:LastName xmlns:ns9="urn:sobject.partner.soap.sforce.com">Badger</ns9:LastName>
     <ns10:Id xmlns:ns10="urn:sobject.partner.soap.sforce.com">00530000000bzOAAAY</ns10:Id>
    </records>
    <size>2</size>
   </result>
  </queryResponse>
 </soapenv:Body>
</soapenv:Envelope>

I'm using the partner wsdl

Thanks.


 

 

DevAngelDevAngel

Hi scoop,

Sorry, no.  There is no way to have the message comeback non-namespace qualified.  The ns for the query result, which is a parent element of the rest of the message is different from the child elements.  This means that the child elements need to have an explicit ns qualification to be propertly de-serialized.

I do believe that there might be some tuning that can be done so that the element namespace is declared once so that the elements will all have the same prefix.  I will talk to our engineers about it.

A better format would be:

<?xml version="1.0"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="urn:sobject.partner.soap.sforce.com">
 <soapenv:Body>
  <queryResponse xmlns="urn:enterprise.soap.sforce.com">
   <result>
    <done>true</done>
    <queryLocator xsi:nil="true"/>
    <records>
     <ns1:type>User</ns1:type>
     <ns1:Username>greg@insidescoop.com</ns1:Username>
     <ns1:FirstName>Greg</ns1:FirstName>
     <ns1:LastName>Campbell</ns1:LastName>
     <ns1:Id>00530000000byXhAAI</ns1:Id>
    </records>
    <records>
     <ns1:type>User</ns1:type>
     <ns1:Username>cbadger@insidescoop.com</ns1:Username>
     <ns1:FirstName>Chris</ns1:FirstName>
     <ns1:LastName>Badger</ns1:LastName>
     <ns1:Id>00530000000bzOAAAY</ns1:Id>
    </records>
    <size>2</size>
   </result>
  </queryResponse>
 </soapenv:Body>
</soapenv:Envelope>