Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Getting error while requesting data from the UPS webservice

506 views
Skip to first unread message

as786

unread,
Jul 26, 2011, 3:52:31 PM7/26/11
to
Hello I'm using PHP curl to request some data from the UPS web service
(denied party screening) and this is what I get:

"HTTP/1.1 200 OK Server: Apache Content-Length: 660 X-Powered-By:
Servlet/2.5 JSP/2.1 Content-Type: text/xml Expires: Tue, 26 Jul 2011
19:45:39 GMT Cache-Control: max-age=0, no-cache, no-store Pragma: no-
cache Date: Tue, 26 Jul 2011 19:45:39 GMT Connection: keep-alive
ClientAn exception has been raised as a result of client
data.Hard10001The XML document is not well formedUnexpected element:
XML_DOC_DECL"

which obviously indicates error in my client data. I've however tried
to match the request XML data according to the XSD schema given from
UPS. Here's my script:

<?php
$url = "https://wwwcie.ups.com/webservices/DeniedParty";
$access_license_number = "myLicenseNumber";
$user_id = "myUserId@ups";
$password = "MyPassword";

$contact_name = "Tariq Ahmed";
$company_name = "";
$address = array (
"AddressLine" => "612 BUSINESS CENTRE MUMTAZ HASAN ROAD OFF I.I.
CHUNDRIGAR ROAD",
"City" => "KARACHI",
"State" => "",
"PostalCode" => "",
"County" => "",
"CountryCode" => "PK");

$match_level = "Low";
$transaction_reference_id = "trans1234";

$data ="<?xml version=\"1.0\"?>
<AccessRequest xml:lang='en-US'>
<AccessLicenseNumber>$access_license_number</AccessLicenseNumber>
<UserId>$user_id</UserId>
<Password>$password</Password>
</AccessRequest>
<?xml version=\"1.0\"?>
<DeniedPartyScreenerRequest>
<Request>
<RequestAction>DeniedPartyScreener</RequestAction>
</Request>
<Party>
<ScreenType>Party</ScreenType>
<ContactName>$contact_name</ContactName>
<CompanyName>$company_name</CompanyName>
<Address>
<AddressLine>$address[AddressLine]</AddressLine>
<City>$address[City]</City>
<State>$address[State]</State>
<PostalCode>$address[PostalCode]</PostalCode>
<County>$address[County]</County>
<CountryCode>$address[CountryCode]</CountryCode>
</Address>
<MatchLevel>$match_level</MatchLevel>
</Party>
<TransactionReferenceID>$transaction_reference_id</
TransactionReferenceID>
</DeniedPartyScreenerRequest>";

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_TIMEOUT, 60);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
$result=curl_exec ($ch);
echo $result;
?>


Here's the XSD schema:

<xsd:schema elementFormDefault="qualified" targetNamespace="http://
www.ups.com/schema/xpci/1.0/dps" xmlns:xsd="http://www.w3.org/2001/
XMLSchema" xmlns:dps="http://www.ups.com/schema/xpci/1.0/dps">
<xsd:element name="DeniedPartyScreenerRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Request" type="dps:RequestTransportType"/>
<xsd:element name="Party" type="dps:PartyType"/>
<xsd:element maxOccurs="3" minOccurs="0"
name="TransactionReferenceID" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="DeniedPartyScreenerResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Response" type="dps:ResponseTransportType"/
>
<xsd:element name="TransactionInfo"
type="dps:TransactionInfoType"/>
<xsd:element maxOccurs="unbounded" minOccurs="0"
name="GovernmentList" type="dps:GovernmentListType"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="ResponseTransportType">
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="Warning"
type="xsd:string"/>
<xsd:element minOccurs="0" name="DeniedPartySearchStatus"
type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="RequestTransportType">
<xsd:sequence>
<xsd:element name="RequestAction" type="xsd:string"/>
<xsd:element maxOccurs="unbounded" minOccurs="0"
name="RequestOption" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="PartyType">
<xsd:sequence>
<xsd:element name="ScreenType" type="xsd:string"/>
<xsd:element minOccurs="0" name="ContactName" type="xsd:string"/
>
<xsd:element minOccurs="0" name="CompanyName" type="xsd:string"/
>
<xsd:element minOccurs="0" name="Address" type="dps:AddressType"/
>
<xsd:element minOccurs="0" name="MatchLevel" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="AddressType">
<xsd:sequence>
<xsd:element maxOccurs="3" minOccurs="0" name="AddressLine"
type="xsd:string"/>
<xsd:element minOccurs="0" name="City" type="xsd:string"/>
<xsd:element minOccurs="0" name="State" type="xsd:string"/>
<xsd:element minOccurs="0" name="PostalCode" type="xsd:string"/>
<xsd:element minOccurs="0" name="County" type="xsd:string"/>
<xsd:element minOccurs="0" name="CountryCode" type="xsd:string"/
>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="TransactionInfoType">
<xsd:sequence>
<xsd:element name="Date" type="xsd:string"/>
<xsd:element name="Time" type="xsd:string"/>
<xsd:element name="TransactionCharge">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="MonetaryValue" type="xsd:string"/>
<xsd:element name="CurrencyCode" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="GovernmentListType">
<xsd:sequence>
<xsd:element name="ListDescription">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="0" name="ListName"
type="xsd:string"/>
<xsd:element minOccurs="0" name="Description"
type="xsd:string"/>
<xsd:element minOccurs="0" name="ControlAgency"
type="xsd:string"/>
<xsd:element minOccurs="0" name="LastRegulatoryUpdate"
type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element maxOccurs="unbounded" minOccurs="0"
name="DeniedParty">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="0" name="Names">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="unbounded" name="Name"
type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element minOccurs="0" name="Addresses">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0"
name="Address" type="dps:AddressType"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element minOccurs="0" name="Remarks"
type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>

Jerry Stuckle

unread,
Jul 26, 2011, 6:45:55 PM7/26/11
to

Why do you have multiple XML doc declarations (<?xml version=\"1.0\"?>)?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstu...@attglobal.net
==================

Doug Miller

unread,
Jul 27, 2011, 9:20:51 AM7/27/11
to
In article <83ef5602-4e59-4c81...@z7g2000vbp.googlegroups.com>, as786 <atindra...@gmail.com> wrote:
>Hello I'm using PHP curl to request some data from the UPS web service
>(denied party screening) and this is what I get:
>
>"HTTP/1.1 200 OK Server: Apache Content-Length: 660 X-Powered-By:
>Servlet/2.5 JSP/2.1 Content-Type: text/xml Expires: Tue, 26 Jul 2011
>19:45:39 GMT Cache-Control: max-age=0, no-cache, no-store Pragma: no-
>cache Date: Tue, 26 Jul 2011 19:45:39 GMT Connection: keep-alive
>ClientAn exception has been raised as a result of client
>data.Hard10001The XML document is not well formedUnexpected element:
>XML_DOC_DECL"
>
>which obviously indicates error in my client data.

And, equally obviously, not a PHP problem of any sort. If you want your XML
problems diagnosed, post in an XML newsgroup.

0 new messages