1

I'm at a brick wall. My first ever post here on stackoverflow, though I use it for solving other problems all the time. This time I can't find an exsisitng solution that solves my problem.

I'm trying to setup xml dropship/ordering from a supplier. But no matter what I do I keep getting the below reture value. The jobs for a friend, so I've no budjet to hire anyone to help me (clever of me to take it on right?)

Destination "nameofcompany API" (ID: 1): API returned: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE XGResponse SYSTEM "http://intcom.xml.quality.nameofcompany.de:8080/XMLGate/XMLGateResponse.dtd"> <XGResponse><Failure code="400"> Failed to parse submitted XML Document.org.xml.sax.SAXParseException: Content is not allowed in prolog. </Failure></XGResponse>

I've tested the xml that gets ouputted, and it all validates fine, I even have that confirmed by the IT department of that company, who conveniantly don't know what's going wrong and have no logs of requests sent to them.

The xsl template is setup as below

<?xml version="1.0" encoding="UTF-8"?>
<files>
<file filename="export_%lastincrementid%.xml"><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:php="http://php.net/xsl" exclude-result-prefixes="php">
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<xsl:template match="/">
<xsl:text disable-output-escaping="yes">&lt;</xsl:text>
<![CDATA[!DOCTYPE OrderEnv SYSTEM "http://integratex.quality.nameofcompany.de:8080/ix/dtd/ixOrder4.dtd"]]>
<xsl:text disable-output-escaping="yes">&gt;</xsl:text>
<!--<!DOCTYPE OrderEnv SYSTEM "http://integratex.nameofcompany.com:8080/ix/dtd/ixOrder4.dtd"> Live-->
<OrderEnv AuthCode="code-goes-here">
<xsl:attribute name="MsgID"><xsl:value-of select="$exportid"/></xsl:attribute>
<xsl:for-each select="orders/order">
<Order>
<xsl:attribute name="Currency"><xsl:value-of select="order_currency_code"/></xsl:attribute>
<Head>
<Title><xsl:value-of select="increment_id"/></Title>
<OrderDate><xsl:value-of select="php:functionString('strftime', '%Y%m%d', created_at_timestamp)"/></OrderDate>
<!--<DelDate></DelDate>--> 
<CustContact></CustContact> 
<!-- <ThirdParty>
<Address> 
<Name1>string</Name1>
<Name2>string</Name2>
<Name3>string</Name3>
<Name4>string</Name4> 
<Street>string</Street> 
<ZIP>string</ZIP> 
<City>string</City> 
<District>string</District> 
<Country>str</Country> 
<ContactName>string</ContactName> 
<ContactPhone>string</ContactPhone> 
<ContactMail>string</ContactMail> 
</Address> </ThirdParty> 
<Reseller> 
<ContactName>string</ContactName> 
<ContactPhone>string</ContactPhone> 
<ContactMail>string</ContactMail> 
</Reseller> --> 
<DeliverTo> 
<Address> 
<Name1><xsl:value-of select="concat(shipping/firstname, ' ', shipping/lastname)"/></Name1>
<Name2><xsl:value-of select="shipping/company"/></Name2>
<Name3></Name3>
<Name4></Name4>
<Street><xsl:value-of select="concat(shipping/street1, ' ', shipping/street2)"/></Street>
<ZIP><xsl:value-of select="shipping/postcode"/></ZIP>
<City><xsl:value-of select="shipping/city"/></City>
<District><xsl:value-of select="shipping/region"/></District>
<Country><xsl:value-of select="shipping/country_id"/></Country>
<!--<DeliveryNoteLanguage></DeliveryNoteLanguage>-->
<ContactName><xsl:value-of select="concat(shipping/firstname, ' ', shipping/lastname)"/></ContactName> <ContactPhone><xsl:value-of select="shipping/telephone"/></ContactPhone>
<ContactMail><xsl:value-of select="customer_email"/></ContactMail>
</Address></DeliverTo>
<Delivery Type="" Condition="y" Full="y" POD="n"/>
<OrigPO><xsl:value-of select="increment_id"/></OrigPO>
<FreeTxt Type="info"></FreeTxt>
<ShipTxt></ShipTxt>
<InvoicTxt></InvoicTxt>
<CODamount><xsl:if test="payment/method='cashondelivery'"><xsl:value-of select="grand_total"/></xsl:if></CODamount>
</Head>
<Body>
<xsl:for-each select="items/item">
<Line>
<xsl:attribute name="ID"><xsl:value-of select="position()"/></xsl:attribute>
<ItemID><xsl:value-of select="sku"/></ItemID>
<Qty><xsl:value-of select="round(qty)"/></Qty>
<Price><xsl:value-of select="php:functionString('number_format', price, 2, '.', '')"/></Price>
<ConfigID></ConfigID>
<AgreementNumber></AgreementNumber>
<BundleID></BundleID>
<EndUserID></EndUserID>
<OrigPO></OrigPO>
<FreeTxt Type="info"></FreeTxt>
<ShipTxt></ShipTxt>
<UsageCode></UsageCode>
<LineType></LineType>
<ConfigNo></ConfigNo>
</Line></xsl:for-each>
</Body>
</Order>
</xsl:for-each>
</OrderEnv>
</xsl:template>
</xsl:stylesheet>
</file>
</files> 

and it ouputs the following xml message

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE OrderEnv SYSTEM "http://integratex.quality.nameofcompany.de:8080/ix/dtd/ixOrder4.dtd"><OrderEnv AuthCode="the-auth-code" MsgID="21">
  <Order Currency="GBP">
    <Head>
      <Title>100000006</Title>
      <OrderDate>20140117</OrderDate>
      <CustContact/>
      <DeliverTo>
        <Address>
          <Name1>Nate</Name1>
          <Name2></Name2>
          <Name3/>
          <Name4/>
          <Street>638 Moave street </Street>
          <ZIP>NE34567</ZIP>
          <City>Fakeville</City>
          <District></District>
          <Country>GB</Country>
          <ContactName>Nate</ContactName>
          <ContactPhone>00098989890</ContactPhone>
          <ContactMail>[email protected]</ContactMail>
        </Address>
      </DeliverTo>
      <Delivery Type="" Condition="y" Full="y" POD="n"/>
      <OrigPO>100000006</OrigPO>
      <FreeTxt Type="info"/>
      <ShipTxt/>
      <InvoicTxt/>
      <CODamount>105.0000</CODamount>
    </Head>
    <Body>
      <Line ID="1">
        <ItemID>1497866</ItemID>
        <Qty>1</Qty>
        <Price>100.00</Price>
        <ConfigID/>
        <AgreementNumber/>
        <BundleID/>
        <EndUserID/>
        <OrigPO/>
        <FreeTxt Type="info"/>
        <ShipTxt/>
        <UsageCode/>
        <LineType/>
        <ConfigNo/>
      </Line>
    </Body>
  </Order>
</OrderEnv>

And below is the http post method (if that's the right way of reffering to it)

    public function nameofcompany($fileArray)

    {

        // Do whatever - sample code for a HTTP request below.

        foreach ($fileArray as $filename => $fileContent) {

            $curlClient = curl_init();

            curl_setopt($curlClient, CURLOPT_URL, 'http://intcom.xml.quality.nameofcompany.de:8080/XMLGate/inbound'); //Prod: http://intcom.xml.nameofcompany-europe.com:8080/XMLGate/inbound

            curl_setopt($curlClient, CURLOPT_RETURNTRANSFER, 1);

            curl_setopt($curlClient, CURLOPT_POST, 1);

            curl_setopt($curlClient, CURLOPT_POSTFIELDS, array('xmlmsg' => $fileContent));

            #curl_setopt($curlClient, CURLOPT_SSL_VERIFYPEER, 0);

            #curl_setopt($curlClient, CURLOPT_SSL_VERIFYHOST, 0);

            $result = curl_exec($curlClient);

$logEntry = Mage::registry('export_log');
$logEntry->addResultMessage(Mage::helper('xtento_orderexport')->__('Destination "%s" (ID: %s): %s', $this->getDestination()->getName(), $this->getDestination()->getId(), 'API returned: '.htmlentities($result)));

            curl_close($curlClient);

        }

    }

To my mind there's something getting thrown into the message when it's being sent, and it's not showing in the xml file log that's getting stored locally on the server, that I showed you above. I even checked the xml file in a hex editor and couldn't find any hint of a DOM or anything else that's being snuck in before the message starts.

NB: I'm quite new to PHP/XML, so if I'm not specific enough anywhere here, or am using the wrong terminology, do forgive me. I'm trying to work most of this out as I go. And if you want me to provide any more details, just say the word.

Cheers Nate

2
  • Any sucess with this issue? I just ran into same problem today. Commented Nov 21, 2014 at 18:40
  • 1
    @NenadBulatovic I did get it working in the end. It worked after the following content type header was sent. Content-Type: application/x-www-form-urlencoded If I can do anything else, let me know. Commented Nov 24, 2014 at 15:07

1 Answer 1

1

Just a guess, have you checked the XML for BOM (byte order mark)?

Sign up to request clarification or add additional context in comments.

2 Comments

thanks for the reply mate. I ran the messages (that are saved locally on the server after the file is sent) through a hex editor, and couldn't see a blessed thing. I'm not sure how to test sending the file direct to myself using the same protocol I would in sending it to the supplier. So all I've been able to do is check the local xml files, which have no errors at all, but I'm guessing they're not including everything that's being sent.
Same happened to me - when I save it locally on disk and try to parse it - everything went OK, but when I try to parse remotely error occurs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.