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
MGuyMGuy 

Weird XML response returned by the SalesForce API

Hi,

 

I've created a small .NET app that connects to SalesForce.com through its web service API (19.0).

 

Following some request, SalesForce returns an invalid XML response, i.e. it contains an empty namespace declaration (xmlns:ns1=""):

 

<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:partner.soap.sforce.com" xmlns:ns1="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sf="urn:sobject.partner.soap.sforce.com"><soapenv:Header><ns1:DebuggingInfo><ns1:debugLog></ns1:debugLog></ns1:DebuggingInfo></soapenv:Header><soapenv:Body><queryResponse><result xsi:type="QueryResult"><done>true</done><queryLocator xsi:nil="true"/><records xsi:type="sf:sObject"><sf:type>Case</sf:type><sf:Id xsi:nil="true"/><sf:Type xsi:nil="true"/></records><size>1</size></result></queryResponse></soapenv:Body></soapenv:Envelope>

 

And the request was:

 

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Header><QueryOptions xmlns="urn:partner.soap.sforce.com"><batchSize>200</batchSize></QueryOptions><SessionHeader xmlns="urn:partner.soap.sforce.com"><sessionId>{SOME_ID}</sessionId></SessionHeader></soap:Header><soap:Body><query xmlns="urn:partner.soap.sforce.com"><queryString>select Type from Case where Id='{SOME_ID}'</queryString></query></soap:Body></soap:Envelope>

 

Where {SOME_ID} is a valid session ID and case ID, respectively.

 

The problem is that when SoapHttpClientProtocol (web reference) parses the response, its internal XmlReader throws an XmlException: "Response is not well-formed XML. ---> System.Xml.XmlException: Invalid namespace declaration. Line 1, position 161."

 

Now my questions are:

 

1- Why does SalesForce return this response (instead of returning the expected query result)?

2- Why does SalesForce return an empty namespace (xmlns:ns1="")? As I explained above, this breaks the XmlReader class (MoveToContent method).

 

Thanks for your help!

 

MGuy

SuperfellSuperfell

How are you capturing this response XML? Which instance are you connecting to? i wasn't able to reproduce this sending your request using curl.

 

Other than the namespace issue, the response looks correct.

MGuyMGuy

1- The way I'm capturing the response XML is simple. I've implemented a SoapExtension that logs requests and reponses to an XML file.

 

2- The instance I'm connecting to is:

 

https://na5-api.salesforce.com/services/Soap/u/19.0/00D700000009KJQ

 

3- What do you mean when you say that the response looks correct?

 

I would expect to receive the value of the 'Type' field of the specified case. However, this is not what I received.

 

4- What's the purpose of the "DebuggingInfo" and "debugLog" nodes? Did an error occur?

 

Thanks!

 

MGuy

 

SuperfellSuperfell

You should probably log a case with support.

KjWhalKjWhal

I am also getting this error, but support cases cannot be opened by developers on standard support any more. Is there a resolution available?