FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Getting error while requesting data from the UPS webservice
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Getting error while requesting data from the UPS webservice [message #174960] Tue, 26 July 2011 19:52 Go to previous message
as786 is currently offline  as786
Messages: 1
Registered: July 2011
Karma:
Junior Member
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>
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: spider PDF
Next Topic: how to make a function recursive
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 15:15:01 GMT 2024

Total time taken to generate the page: 0.04772 seconds