473,408 Members | 2,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

UPS Tracking

I am trying to get tracking information from UPS web site without much luck. I got this working in VB 60 without any problems by using WinInet functions

Here my test program. We need to get Tracking information from www.ups.com/ups.app/xml/track. When I tried to create the WebRequest with above ulr I get server not found. If I try www.ups.com, I do get connected but how I can post my message to ups.app/xml/track

I appricate your help in solving this problem

string url = "http://www.ups.com";
string UserName="testUser"
string UserPassword="testPW ";
string XmlRequest
string XmlResponse;

string hostname="wwwcie.ups.com"
string prefix = "ups.app/xml"
string service ="track"
//URL url = new URL(protocol + "://" + hostname + "/" + prefix + "/" + service)

url = "http://" + hostname + "/" + prefix + "/" + service
XmlRequest =
"<?xml version=1.0?>"
" <TrackRequest xml:lang=en-US>"
"<Request><TransactionReference>"
"<CustomerContext>Example 1</CustomerContext>"
"<XpciVersion>1.0001</XpciVersion>"
"</TransactionReference>"
"<RequestAction>Track</RequestAction>"
"<RequestOption>activity</RequestOption></Request>"
"<TrackingNumber>" + "1Z12345E0291980793" + "</TrackingNumber></TrackRequest>"

//WebProxy proxyObject = new WebProxy("http://wwwcie.ups.com:8080")

// Disable Proxy use when the host is local i.e. without periods
//proxyObject.BypassProxyOnLocal = true;

HttpWebRequest myHttpWebRequest = (HttpWebRequest) WebRequest.Create(url)
myHttpWebRequest.Credentials = new NetworkCredential(UserName,UserPassword )
myHttpWebRequest.Method = "POST"
myHttpWebRequest.KeepAlive = false
//myHttpWebRequest.Connection = "/ups.app/xml/track";
myHttpWebRequest.UserAgent = "Test XML Request";

myHttpWebRequest.ContentType = "application/x-www-form-urlencoded"

// Set the 'ContentLength' property of the WebRequest
myHttpWebRequest.ContentLength = XmlRequest.Length;

Stream SendStream=myHttpWebRequest.GetRequestStream();

ASCIIEncoding encodedData=new ASCIIEncoding()
byte[] byteArray=encodedData.GetBytes(XmlRequest)

SendStream.Write(byteArray,0,byteArray.Length)

HttpWebResponse WebResp = (HttpWebResponse) myHttpWebRequest.GetResponse()

// Now read the data from respons
//Get a readable stream from the server.
Stream RecvStream = WebResp.GetResponseStream()

byte[] readBuff = new byte[256]

int bytesread
XmlResponse = ""
//Read from the stream and write any data to the console
bytesread = RecvStream.Read( readBuff, 0, 256)
while( bytesread > 0 )
{
bytesread = RecvStream.Read( readBuff, 0, 256)
XmlResponse = XmlResponse + readBuff
MessageBox.Show(XmlResponse)

RecvStream.Close()
WebResp.Close();
Nov 18 '05 #1
5 7354
The track is Case Sensitive Should be "Track"
"HttpWebRequest" <an*******@discussions.microsoft.com> wrote in message
news:03**********************************@microsof t.com...
I am trying to get tracking information from UPS web site without much luck. I got this working in VB 60 without any problems by using WinInet
functions.
Here my test program. We need to get Tracking information from www.ups.com/ups.app/xml/track. When I tried to create the WebRequest with
above ulr I get server not found. If I try www.ups.com, I do get connected
but how I can post my message to ups.app/xml/track.
I appricate your help in solving this problem.

string url = "http://www.ups.com";
string UserName="testUser";
string UserPassword="testPW ";
string XmlRequest;
string XmlResponse;

string hostname="wwwcie.ups.com";
string prefix = "ups.app/xml";
string service ="track";
//URL url = new URL(protocol + "://" + hostname + "/" + prefix + "/" + service);
url = "http://" + hostname + "/" + prefix + "/" + service;
XmlRequest =
"<?xml version=1.0?>" +
" <TrackRequest xml:lang=en-US>" +
"<Request><TransactionReference>" +
"<CustomerContext>Example 1</CustomerContext>" +
"<XpciVersion>1.0001</XpciVersion>" +
"</TransactionReference>" +
"<RequestAction>Track</RequestAction>" +
"<RequestOption>activity</RequestOption></Request>" +
"<TrackingNumber>" + "1Z12345E0291980793" + "</TrackingNumber></TrackRequest>";
//WebProxy proxyObject = new WebProxy("http://wwwcie.ups.com:8080");

// Disable Proxy use when the host is local i.e. without periods.
//proxyObject.BypassProxyOnLocal = true;

HttpWebRequest myHttpWebRequest = (HttpWebRequest) WebRequest.Create(url);
myHttpWebRequest.Credentials = new etworkCredential(UserName,UserPassword ); myHttpWebRequest.Method = "POST";
myHttpWebRequest.KeepAlive = false;
//myHttpWebRequest.Connection = "/ups.app/xml/track";
myHttpWebRequest.UserAgent = "Test XML Request";

myHttpWebRequest.ContentType = "application/x-www-form-urlencoded";

// Set the 'ContentLength' property of the WebRequest.
myHttpWebRequest.ContentLength = XmlRequest.Length;

Stream SendStream=myHttpWebRequest.GetRequestStream();

ASCIIEncoding encodedData=new ASCIIEncoding();
byte[] byteArray=encodedData.GetBytes(XmlRequest);

SendStream.Write(byteArray,0,byteArray.Length);

HttpWebResponse WebResp = (HttpWebResponse) myHttpWebRequest.GetResponse();
// Now read the data from response
//Get a readable stream from the server.
Stream RecvStream = WebResp.GetResponseStream();

byte[] readBuff = new byte[256];

int bytesread;
XmlResponse = "";
//Read from the stream and write any data to the console.
bytesread = RecvStream.Read( readBuff, 0, 256);
while( bytesread > 0 )
{
bytesread = RecvStream.Read( readBuff, 0, 256);
XmlResponse = XmlResponse + readBuff;
MessageBox.Show(XmlResponse);
}
RecvStream.Close();
WebResp.Close();

Nov 18 '05 #2
The track is Case Sensitive Should be "Track"

"HttpWebRequest" <an*******@discussions.microsoft.com> wrote in message
news:03**********************************@microsof t.com...
I am trying to get tracking information from UPS web site without much luck. I got this working in VB 60 without any problems by using WinInet
functions.
Here my test program. We need to get Tracking information from www.ups.com/ups.app/xml/track. When I tried to create the WebRequest with
above ulr I get server not found. If I try www.ups.com, I do get connected
but how I can post my message to ups.app/xml/track.
I appricate your help in solving this problem.

string url = "http://www.ups.com";
string UserName="testUser";
string UserPassword="testPW ";
string XmlRequest;
string XmlResponse;

string hostname="wwwcie.ups.com";
string prefix = "ups.app/xml";
string service ="track";
//URL url = new URL(protocol + "://" + hostname + "/" + prefix + "/" + service);
url = "http://" + hostname + "/" + prefix + "/" + service;
XmlRequest =
"<?xml version=1.0?>" +
" <TrackRequest xml:lang=en-US>" +
"<Request><TransactionReference>" +
"<CustomerContext>Example 1</CustomerContext>" +
"<XpciVersion>1.0001</XpciVersion>" +
"</TransactionReference>" +
"<RequestAction>Track</RequestAction>" +
"<RequestOption>activity</RequestOption></Request>" +
"<TrackingNumber>" + "1Z12345E0291980793" + "</TrackingNumber></TrackRequest>";
//WebProxy proxyObject = new WebProxy("http://wwwcie.ups.com:8080");

// Disable Proxy use when the host is local i.e. without periods.
//proxyObject.BypassProxyOnLocal = true;

HttpWebRequest myHttpWebRequest = (HttpWebRequest) WebRequest.Create(url);
myHttpWebRequest.Credentials = new etworkCredential(UserName,UserPassword ); myHttpWebRequest.Method = "POST";
myHttpWebRequest.KeepAlive = false;
//myHttpWebRequest.Connection = "/ups.app/xml/track";
myHttpWebRequest.UserAgent = "Test XML Request";

myHttpWebRequest.ContentType = "application/x-www-form-urlencoded";

// Set the 'ContentLength' property of the WebRequest.
myHttpWebRequest.ContentLength = XmlRequest.Length;

Stream SendStream=myHttpWebRequest.GetRequestStream();

ASCIIEncoding encodedData=new ASCIIEncoding();
byte[] byteArray=encodedData.GetBytes(XmlRequest);

SendStream.Write(byteArray,0,byteArray.Length);

HttpWebResponse WebResp = (HttpWebResponse) myHttpWebRequest.GetResponse();
// Now read the data from response
//Get a readable stream from the server.
Stream RecvStream = WebResp.GetResponseStream();

byte[] readBuff = new byte[256];

int bytesread;
XmlResponse = "";
//Read from the stream and write any data to the console.
bytesread = RecvStream.Read( readBuff, 0, 256);
while( bytesread > 0 )
{
bytesread = RecvStream.Read( readBuff, 0, 256);
XmlResponse = XmlResponse + readBuff;
MessageBox.Show(XmlResponse);
}
RecvStream.Close();
WebResp.Close();

Nov 18 '05 #3
I tried like you suggested, I still can't get it working. By any chance you have an example to get tracking information. (Any language is fine)
Nov 18 '05 #4
The URL is HTTPS://www.ups.com/ups.app/xml/Track
click thee above link and you will get a response from the server. Your
code looks fine. I would include the code for you but I have it wrapped up
in a large class file that accesses other carriers. If you really get stuck
I will send it to you.

"HttpWebRequest" <an*******@discussions.microsoft.com> wrote in message
news:03**********************************@microsof t.com...
I am trying to get tracking information from UPS web site without much luck. I got this working in VB 60 without any problems by using WinInet
functions.
Here my test program. We need to get Tracking information from www.ups.com/ups.app/xml/track. When I tried to create the WebRequest with
above ulr I get server not found. If I try www.ups.com, I do get connected
but how I can post my message to ups.app/xml/track.
I appricate your help in solving this problem.

string url = "http://www.ups.com";
string UserName="testUser";
string UserPassword="testPW ";
string XmlRequest;
string XmlResponse;

string hostname="wwwcie.ups.com";
string prefix = "ups.app/xml";
string service ="track";
//URL url = new URL(protocol + "://" + hostname + "/" + prefix + "/" + service);
url = "http://" + hostname + "/" + prefix + "/" + service;
XmlRequest =
"<?xml version=1.0?>" +
" <TrackRequest xml:lang=en-US>" +
"<Request><TransactionReference>" +
"<CustomerContext>Example 1</CustomerContext>" +
"<XpciVersion>1.0001</XpciVersion>" +
"</TransactionReference>" +
"<RequestAction>Track</RequestAction>" +
"<RequestOption>activity</RequestOption></Request>" +
"<TrackingNumber>" + "1Z12345E0291980793" + "</TrackingNumber></TrackRequest>";
//WebProxy proxyObject = new WebProxy("http://wwwcie.ups.com:8080");

// Disable Proxy use when the host is local i.e. without periods.
//proxyObject.BypassProxyOnLocal = true;

HttpWebRequest myHttpWebRequest = (HttpWebRequest) WebRequest.Create(url);
myHttpWebRequest.Credentials = new etworkCredential(UserName,UserPassword ); myHttpWebRequest.Method = "POST";
myHttpWebRequest.KeepAlive = false;
//myHttpWebRequest.Connection = "/ups.app/xml/track";
myHttpWebRequest.UserAgent = "Test XML Request";

myHttpWebRequest.ContentType = "application/x-www-form-urlencoded";

// Set the 'ContentLength' property of the WebRequest.
myHttpWebRequest.ContentLength = XmlRequest.Length;

Stream SendStream=myHttpWebRequest.GetRequestStream();

ASCIIEncoding encodedData=new ASCIIEncoding();
byte[] byteArray=encodedData.GetBytes(XmlRequest);

SendStream.Write(byteArray,0,byteArray.Length);

HttpWebResponse WebResp = (HttpWebResponse) myHttpWebRequest.GetResponse();
// Now read the data from response
//Get a readable stream from the server.
Stream RecvStream = WebResp.GetResponseStream();

byte[] readBuff = new byte[256];

int bytesread;
XmlResponse = "";
//Read from the stream and write any data to the console.
bytesread = RecvStream.Read( readBuff, 0, 256);
while( bytesread > 0 )
{
bytesread = RecvStream.Read( readBuff, 0, 256);
XmlResponse = XmlResponse + readBuff;
MessageBox.Show(XmlResponse);
}
RecvStream.Close();
WebResp.Close();

Nov 18 '05 #5
I got it working. The magic is https, I am using http. It is working fine after I changed it to htpps

Thanks for your help.
Nov 18 '05 #6

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

Similar topics

6
by: Tran Tuan Anh | last post by:
Hi all, I am new to Python and desperated to look for a good Python debugger. I mean a debugger with source coding tracking. For C/C++, emacs and gud offers execellent development env. The...
3
by: Kyle Friesen via AccessMonster.com | last post by:
Mike, I have databse that creates a "tracking number" based on the selections made on the form via concatenating. At the end of the tracking number, I need a two digit (01-99) sequence number by...
2
by: | last post by:
Hi!!! I'm looking for an ASP.NET bug tracking web application. ´ Or some others that are based on the web. What kind of bug tracking applications used Microsoft to track bugs? Or what kind of...
6
by: A.M-SG | last post by:
Hi, We are developing a SmartClient application and we are planning to expose business objects layer to SmartClient application by using ASP.NET SOAP web services.
2
by: C# programmer | last post by:
Hi All, I'm working on a project which requires tracking of recent document downloads. There is a feature in which user can download the docs without logining into the website for some of the...
1
by: bdockery | last post by:
So I figured out that if you use this html: http://wwwapps.ups.com/WebTracking/processInputRequest?sort_by=status&tracknums_displayed=1&TypeOfInquiryNumber=T&loc=en_US&InquiryNumber1=<TRACKING...
3
by: =?Utf-8?B?R3JhaGFt?= | last post by:
I've added 2 tracking services to the wf runtime; one is the standard SqlTrackingService: trackingService = new SqlTrackingService(<trackingConnectionString>); <workflow...
0
by: LiveTecs | last post by:
http://www.livetecs.com TimeLive Web Collaboration Suite is an integrated suite that allows you to manage project life cycle including tasks, issues, bugs, timesheet, expense, attendance. ...
5
by: jennic | last post by:
Hi, I have an online shop that uses Sunshop php shopping cart and I have attempted to get help through their forum but no-one responds with assistance. I need to install a tracking code on my site...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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...
0
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...
0
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...
0
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,...
0
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...

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.