Skip to Content
avatar image
Former Member

SAP NW GW - Error while parsing an XML stream: 'BOM / charset detection failed'

Hello Experts,

For a customer project, we have to implement a Sales Order Creation in OData. I created a Gateway project based on the BAPI_SALESORDER_CREATE2. I created the 3 entities I need (Header, Item and Partner).

I tested the BAPI with my data and everything is fine.

Now I tried to test it through the GW_CLIENT.

I got already a lot of errors that I was able to correct with SCN messages (thanks a lot !) but now I have a 'Error while parsing an XML stream: 'BOM / charset detection failed'.

I understood something is wrong with my XML file but the "Check XML" is ok and I have no idea what can be wrong in my simple XML test file !

Any help is appreciated.

Here is the file:

<?xml version="1.0" encoding="UTF-8"?>

<entry xml:base="http://xx/sap/opu/odata/sap/Z_SALESORDER_CREATE2_SRV/" xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices">

<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/OrderSalesHeader" type="application/atom+xml;type=feed" title="Z_SALESORDER_CREATE2_SRV.OrderSalesHeader">

  <m:inline>

   <feed>

    <entry>

     <content type="application/xml">

      <m:properties>

       <d:DocType>TA</d:DocType>

       <d:SalesOrg>1100</d:SalesOrg>

       <d:DistrChan>01</d:DistrChan>

       <d:Division>01</d:Division>

      </m:properties>

     </content>

    </entry>

   </feed>

  </m:inline>

</link>

<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/HeaderItem" type="application/atom+xml;type=feed" title="Z_SALESORDER_CREATE2_SRV.HeaderToItem">

  <m:inline>

   <feed>

    <entry>

     <content type="application/xml">

      <m:properties>

       <d:Material>AIGL0232</d:Material>

       <d:TargetQu>100</d:TargetQu>

      </m:properties>

     </content>

    </entry>

   </feed>

  </m:inline>

</link>

<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/HeaderPartner" type="application/atom+xml;type=feed" title="Z_SALESORDER_CREATE2_SRV.HeaderToPartner">

  <m:inline>

   <feed>

    <entry>

     <content type="application/xml">

      <m:properties>

       <d:PartnRole>SP</d:PartnRole>

       <d:PartnNumb>YOU001</d:PartnNumb>

      </m:properties>

     </content>

    </entry>

   </feed>

  </m:inline>

</link>

</entry>

Thanks,

Luc

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Oct 15, 2015 at 05:55 AM

    Hi Luc,

    Could you please try and test with below payload

    <?xml version="1.0" encoding="UTF-8"?>

    <atom:entry

    xmlns:atom="http://www.w3.org/2005/Atom"

    xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices"

    xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">

    <atom:content type="application/xml">

    <m:properties>

    <d:DocType>TA</d:DocType>

    <d:SalesOrg>1100</d:SalesOrg>

    <d:DistrChan>01</d:DistrChan>

    <d:Division>01</d:Division>

    </m:properties>

    </atom:content>

    <atom:link

    rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/HeaderItem"

    type="application/atom+xml;type=feed"

    title="Z_SALESORDER_CREATE2_SRV.HeaderToItem">

    <m:inline>

    <atom:feed>

    <atom:entry>

    <atom:content type="application/xml">

    <m:properties>

    <d:Material>AIGL0232</d:Material>

    <d:TargetQu>100</d:TargetQu>

    </m:properties>

    </atom:content>

    </atom:entry>

    </atom:feed>

    </m:inline>

    </atom:link>

    <atom:link

    rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/HeaderPartner"

    type="application/atom+xml;type=feed"

    title="Z_SALESORDER_CREATE2_SRV.HeaderToPartner">

    <m:inline>

    <atom:feed>

    <atom:entry>

    <atom:content type="application/xml">

    <m:properties>

    <d:PartnRole>SP</d:PartnRole>

    <d:PartnNumb>YOU001</d:PartnNumb>

    </m:properties>

    </atom:content>

    </atom:entry>

    </atom:feed>

    </m:inline>

    </atom:link>

    </atom:entry>

    Thanks,

    Syam

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hello Syam,

      Thanks this is much better !

      Now I have a error 400 : No default virus profile active or found. Please check the offical guide.

      I will investigate that...

      Thanks again,

      Luc

  • avatar image
    Former Member
    Oct 15, 2015 at 04:18 AM

    Hello Luc,

    What are the headers you passed for the xml payload ?

    Meanwhile can you try with the below JSON Payload ?

    Pass below headers only :

    x-csrf-token : XXXXXXXXXXX

    Content-Type : application/json

    Method : POST

    {

    "DocType":"TA",

    "SalesOrg":"1100",

    "DistrChan":"01",

    "Division":"01",

    "HeaderItem":[{"Material":"AIGL0232","TargetQu":"100"}],

    "HeaderPartner":[{"PartnRole":"SP","PartnNumb":"YOU001"}]

    }

    Regards,

    Ashwin

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Thanks Ashwin,

      In the header I have only the X-CSRF-Token.

      When I try I get an error 400 :

      System expected the element '{http://www.w3.org/2005/Atom}entry'

      I feel my header is not complete, I will investigate.

      Thanks a lot, I wanted to try with json but was not sure about the syntax !

      Luc

  • Oct 15, 2015 at 05:33 AM

    Hi Luc,

    Is it Get call is working fine..

    Can you try posting same XML format which you receive on calling get operation.

    It looks like some thing missing in XML.

    Regards

    Vivek

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Vivek,

      I didn't implemented the get operation. I did it in another OData service with the BAPI_SALESORDERS_GETLIST.

      I understand something is missing better than a bad XML syntax.

      Regards,

      Luc