• MGuy
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies

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

  • September 13, 2011
  • Like
  • 0

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

  • September 13, 2011
  • Like
  • 0