UPS shipping plugin in Nopcommerce 3.5 XML document is not well formed

419 views Asked by At

I am developing in nopcommerce 3.5.I developed one plugin for shipping UPS and call TransitInTime API. Now I want to use UPS plugin because I want rates from UPS shipping Method with my TransitInTime API. but I am getting Error: error code 10001 and Description: XML Document is not well formed in responce. of XML.

In Request I passed:

<?xml version='1.0'?>
<AccessRequest xml:lang='en-US'>
    <AccessLicenseNumber>CC....</AccessLicenseNumber>
    <UserId>gi...</UserId>
    <Password>Ch...</Password>
</AccessRequest>
<?xml version='1.0'?>
<RatingServiceSelectionRequest xml:lang='en-US'>
    <Request>
        <TransactionReference>
            <CustomerContext>
Bare Bones Rate Request
</CustomerContext>
            <XpciVersion>
1.0001
</XpciVersion>
        </TransactionReference>
        <RequestAction>
Rate
</RequestAction>
        <RequestOption>
Shop
</RequestOption>
    </Request>
    <PickupType>
        <Code>06</Code>
    </PickupType>
    <CustomerClassification>
        <Code>04</Code>
    </CustomerClassification>
    <Shipment>
        <Shipper>
            <Address>
                <PostalCode>35006</PostalCode>
                <CountryCode>US</CountryCode>
            </Address>
        </Shipper>
        <ShipTo>
            <Address>
                <ResidentialAddressIndicator/>
                <PostalCode>35005</PostalCode>
                <CountryCode>US</CountryCode>
            </Address>
        </ShipTo>
        <ShipFrom>
            <Address>
                <PostalCode>35006</PostalCode>
                <CountryCode>US</CountryCode>
            </Address>
        </ShipFrom>
        <Service>
            <Code>03</Code>
        </Service>
        <Package>
            <PackagingType>
                <Code>02</Code>
            </PackagingType>
            <Dimensions>
                <Length>0</Length>
                <Width>0</Width>
                <Height>0</Height>
            </Dimensions>
            <PackageWeight>
                <Weight>18</Weight>
            </PackageWeight>
        </Package>
    </Shipment>
</RatingServiceSelectionRequest>

and In responce:

<soapenv:Envelope
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Header/>
    <soapenv:Body>
        <soapenv:Fault>
            <faultcode>Client</faultcode>
            <faultstring>An exception has been raised as a result of client data.</faultstring>
            <detail>
                <err:Errors
                    xmlns:err="http://www.ups.com/schema/xpci/1.0/error">
                    <err:ErrorDetail>
                        <err:Severity>Hard</err:Severity>
                        <err:PrimaryErrorCode>
                            <err:Code>
10001
</err:Code>
                            <err:Description>
The XML document is not well formed
</err:Description>
                            <err:Digest>
Unexpected element: XML_DOC_DECL
</err:Digest>
                        </err:PrimaryErrorCode>
                        <err:Location/>
                    </err:ErrorDetail>
                </err:Errors>
            </detail>
        </soapenv:Fault>
    </soapenv:Body>
</soapenv:Envelope>
1

There are 1 answers

0
Mickey On

You are using <?xml version='1.0'?> twice. Remove the inner one and use XMl envelope---

example

<?xml version="1.0" encoding="UTF-8"?>
<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:RequestHeader
         soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next"
         soapenv:mustUnderstand="0"
         xmlns:ns1="https://www.google.com/apis/ads/publisher/v201605">
      <ns1:networkCode>123456</ns1:networkCode>
      <ns1:applicationName>DfpApi-Java-2.1.0-dfp_test</ns1:applicationName>
    </ns1:RequestHeader>
  </soapenv:Header>
  <soapenv:Body>
    <getAdUnitsByStatement xmlns="https://www.google.com/apis/ads/publisher/v201605">
      <filterStatement>
        <query>WHERE parentId IS NULL LIMIT 500</query>
      </filterStatement>
    </getAdUnitsByStatement>
  </soapenv:Body>
</soapenv:Envelope>