473,842 Members | 1,600 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

xml-rpc+php+socket --> UPS online tool

Hi,

I am trying to make a php script to calculate the shiping charge
automatically by communicating to UPS online tool.

In order to do that, I used:
1. XML-RPC implemented by Keith Devens
http://www.keithdevens.com/software/xmlrpc/
2. PHP Version 4.3.3 w/ '--with-openssl'
3. The code below is for testing to see if I can communicate to UPS;
but no luck.
4. looks like the code successfully open the socket and send xml to
UPS.
5. but I dont' get anything back or retreiving the response is
invalid?
6. here is my code
7. Please somebody fix me.

<?php
/* Include the library */
include ( "kd_xmlrpc. php" );

/* Define variables to find the rpc server script */
$site = "www.ups.com:44 3";
$location = "/ups.app/xml/AV";
$upsAccessLicen seNumber = "myAccessLiscen seNumber"; //
2BAADC11591CC24 8
$upsUserID = "myID";
$upsPassWord = "myPW";
$upsXpciVersion = "1.0001";
function XMLRPC4UPSAV_re quest($city, $state=NULL, $zip=NULL){

global $site, $location, $upsAccessLicen seNumber, $upsUserID,
$upsPassWord, $upsXpciVersion ;

list($site, $port) = explode(':', $site);
if(!is_numeric( $port)){$port = 80;}

echo $site . "<br>" . $port . "<p>";

//Access Request
$accessData["AccessRequ est"]["AccessLicenseN umber"] =
$upsAccessLicen seNumber;
$accessData["AccessRequ est"]["UserId"] = $upsUserID;
$accessData["AccessRequ est"]["Password"] = $upsPassWord;

$accessData = XML_serialize($ accessData);

// Address Validation Request
$avData["AddressValidat ionRequest"]["Request"]["TransactionRef erence"]["CustomerContex t"]
= "AV TEST";
$avData["AddressValidat ionRequest"]["Request"]["TransactionRef erence"]["XpciVersio n"]
= $upsXpciVersion ;
$avData["AddressValidat ionRequest"]["Request"]["RequestAct ion"] =
"AV";
$avData["AddressValidat ionRequest"]["Address"]["City"] = $city;

if(isset($state ))$avData["AddressValidat ionRequest"]["Address"]["StateProvinceC ode"]
= $state;
if(isset($zip)) $avData["AddressValidat ionRequest"]["Address"]["PostalCode "]
= $zip;

$avData = XML_serialize($ avData);

// combine Access Request & AV Request
$data = $accessData . $avData;

$conn = fsockopen ($site, $port); #open the connection

if(!$conn){ #if the connection was not opened successfully
echo "Failed";
}else{
$headers =
"POST $location HTTP/1.0\r\n" .
"Content-Type: application/x-www-form-urlencoded\r\n" .
"Content-Length: " . strlen($data) . "\r\n\r\n";

fputs($conn, $headers);
fputs($conn, $data);

$response = "";
while(!feof($co nn)){ $response .= fgets($conn, 1024); }
fclose($conn);

#strip headers off of response
$data = XML_unserialize (substr($respon se, strpos($respons e,
"\r\n\r\n")+4)) ;

return $data;
}
}
?>
<html>
<head>
<title> UPS Address Validator</title>
<meta name="Generator " content="EditPl us">
<meta name="Author" content="Jason" >
<meta name="Keywords" content="XML RPC">
<meta name="Descripti on" content="UPS AV">
</head>

<body>
<?
print_r(XMLRPC4 UPSAV_request(" Little Ferry", "NJ"));
?>
</body>
</html>
Jul 17 '05 #1
0 3258

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

24
2729
by: jason | last post by:
Hi Ray...a while ago you explained an elegant solution to enable me to CREATE and EDIT existing tables and queries inside my online access 2000 database.... could you provide refresher links on this or possibly some starter code? I am just so sick of the syncronization problems that come into play when you adjust underlying tables and queries offline and then have to overwrite the live database? Many thanks Jason
1
1815
by: Wolfgang Keller | last post by:
Hello, just as an introduction: I'm not a developer by profession, I just need a solution for this within the scope of a single project... What I am looking for is basically a tool (usable for non-developers) to (semi-)automatically create a relational database schema (MySQL) from an ..xsd schema (and vice-versa) as well as to generate entries into the database from an XML document (and vice-versa).
10
2610
by: Jason Collins | last post by:
There are some Requests that occur that have a NULL UserAgent. Some of these are legitimate crawlers (e.g., Overture's crawler), and I'm attempting to adjust my <browserCaps> to correctly classify crawlers. In an attempt to capture browsers with (UserAgent == null), I've added a case like this: <filter> <case match="^$"> crawler=true
1
3385
by: Clara Yeung | last post by:
I have captured some SOAP messages (using org.wsi.test.monitor.Monitor of the WSI test tool). When I try to analyze the messages with WSI test tool analyzer, the "message" artifact of the report always return "Missing Input". I have tried various "correlationType: endpoint, operation, namespace". When I eyeball the captured SOAP messages, they looks fine with correct namespace and valid operation name within the soap body of the...
0
1917
by: yoshita | last post by:
Hi there! As i understand from the UPS rate and service guide I need to create an XML post to the UPS online tool server and get a response XML. Could anyone guide me with how to code in .net C# to post the XML to the server? I am could not find any documentation to the same. Kind Regards Yoshita
0
1098
by: =?Utf-8?B?Sm9uYXRoYW4=?= | last post by:
Hi, we have a number of clients that range from corporates to single users. Currently our applications are written in MS Access. However the corporates are requesting that we migrate to dot Net and MS SQL. One of the advantages of MS Access is the built-in reporting capability. My question is what reporting tool can you suggest that can be bundled with a dot Net application and will run on a stand-alone PC (with SQL Express) as...
0
1130
by: shapper | last post by:
Hello, I used an online tool to covert a VB.NET code I had to C# that I know use: <ConfigurationProperty("Google")_ Public ReadOnly Property Google() As ElementCollection Get Return TryCast(Me("Google"), ElementCollection) End Get
4
2401
by: Naga Prakash | last post by:
Hello All, I'm very much new to PERL scripting. I'm the admin for an online tool which has some Perl scripts. And i have a problem executing one of the script. I'm just writing a problematic code in the script: my $ex = Win32::OLE->new('CamCad.application') or die "oops\n"; my @args = (25,"$basedir\\SYM.TXT,$basedir\\RTE.TXT,$basedir\\BRD.TXT,$basedir\\PAD.TXT",''); $ex->Invoke('Import',@args); Now when the first line is executed, a...
0
9871
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9715
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10610
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10672
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10313
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9453
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7855
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5696
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
4089
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.