473,666 Members | 2,604 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="testU ser"
string UserPassword="t estPW ";
string XmlRequest
string XmlResponse;

string hostname="wwwci e.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><Tran sactionReferenc e>"
"<CustomerConte xt>Example 1</CustomerContext >"
"<XpciVersion>1 .0001</XpciVersion>"
"</TransactionRefe rence>"
"<RequestAction >Track</RequestAction>"
"<RequestOption >activity</RequestOption></Request>"
"<TrackingNumbe r>" + "1Z12345E029198 0793" + "</TrackingNumber> </TrackRequest>"

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

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

HttpWebRequest myHttpWebReques t = (HttpWebRequest ) WebRequest.Crea te(url)
myHttpWebReques t.Credentials = new NetworkCredenti al(UserName,Use rPassword )
myHttpWebReques t.Method = "POST"
myHttpWebReques t.KeepAlive = false
//myHttpWebReques t.Connection = "/ups.app/xml/track";
myHttpWebReques t.UserAgent = "Test XML Request";

myHttpWebReques t.ContentType = "applicatio n/x-www-form-urlencoded"

// Set the 'ContentLength' property of the WebRequest
myHttpWebReques t.ContentLength = XmlRequest.Leng th;

Stream SendStream=myHt tpWebRequest.Ge tRequestStream( );

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

SendStream.Writ e(byteArray,0,b yteArray.Length )

HttpWebResponse WebResp = (HttpWebRespons e) myHttpWebReques t.GetResponse()

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

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.Clos e()
WebResp.Close() ;
Nov 18 '05 #1
5 7366
The track is Case Sensitive Should be "Track"
"HttpWebRequest " <an*******@disc ussions.microso ft.com> wrote in message
news:03******** *************** ***********@mic rosoft.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="testU ser";
string UserPassword="t estPW ";
string XmlRequest;
string XmlResponse;

string hostname="wwwci e.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><Tran sactionReferenc e>" +
"<CustomerConte xt>Example 1</CustomerContext >" +
"<XpciVersion>1 .0001</XpciVersion>" +
"</TransactionRefe rence>" +
"<RequestAction >Track</RequestAction>" +
"<RequestOption >activity</RequestOption></Request>" +
"<TrackingNumbe r>" + "1Z12345E029198 0793" + "</TrackingNumber> </TrackRequest>";
//WebProxy proxyObject = new WebProxy("http://wwwcie.ups.com: 8080");

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

HttpWebRequest myHttpWebReques t = (HttpWebRequest ) WebRequest.Crea te(url);
myHttpWebReques t.Credentials = new etworkCredentia l(UserName,User Password ); myHttpWebReques t.Method = "POST";
myHttpWebReques t.KeepAlive = false;
//myHttpWebReques t.Connection = "/ups.app/xml/track";
myHttpWebReques t.UserAgent = "Test XML Request";

myHttpWebReques t.ContentType = "applicatio n/x-www-form-urlencoded";

// Set the 'ContentLength' property of the WebRequest.
myHttpWebReques t.ContentLength = XmlRequest.Leng th;

Stream SendStream=myHt tpWebRequest.Ge tRequestStream( );

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

SendStream.Writ e(byteArray,0,b yteArray.Length );

HttpWebResponse WebResp = (HttpWebRespons e) myHttpWebReques t.GetResponse() ;
// Now read the data from response
//Get a readable stream from the server.
Stream RecvStream = WebResp.GetResp onseStream();

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.Clos e();
WebResp.Close() ;

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

"HttpWebRequest " <an*******@disc ussions.microso ft.com> wrote in message
news:03******** *************** ***********@mic rosoft.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="testU ser";
string UserPassword="t estPW ";
string XmlRequest;
string XmlResponse;

string hostname="wwwci e.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><Tran sactionReferenc e>" +
"<CustomerConte xt>Example 1</CustomerContext >" +
"<XpciVersion>1 .0001</XpciVersion>" +
"</TransactionRefe rence>" +
"<RequestAction >Track</RequestAction>" +
"<RequestOption >activity</RequestOption></Request>" +
"<TrackingNumbe r>" + "1Z12345E029198 0793" + "</TrackingNumber> </TrackRequest>";
//WebProxy proxyObject = new WebProxy("http://wwwcie.ups.com: 8080");

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

HttpWebRequest myHttpWebReques t = (HttpWebRequest ) WebRequest.Crea te(url);
myHttpWebReques t.Credentials = new etworkCredentia l(UserName,User Password ); myHttpWebReques t.Method = "POST";
myHttpWebReques t.KeepAlive = false;
//myHttpWebReques t.Connection = "/ups.app/xml/track";
myHttpWebReques t.UserAgent = "Test XML Request";

myHttpWebReques t.ContentType = "applicatio n/x-www-form-urlencoded";

// Set the 'ContentLength' property of the WebRequest.
myHttpWebReques t.ContentLength = XmlRequest.Leng th;

Stream SendStream=myHt tpWebRequest.Ge tRequestStream( );

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

SendStream.Writ e(byteArray,0,b yteArray.Length );

HttpWebResponse WebResp = (HttpWebRespons e) myHttpWebReques t.GetResponse() ;
// Now read the data from response
//Get a readable stream from the server.
Stream RecvStream = WebResp.GetResp onseStream();

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.Clos e();
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*******@disc ussions.microso ft.com> wrote in message
news:03******** *************** ***********@mic rosoft.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="testU ser";
string UserPassword="t estPW ";
string XmlRequest;
string XmlResponse;

string hostname="wwwci e.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><Tran sactionReferenc e>" +
"<CustomerConte xt>Example 1</CustomerContext >" +
"<XpciVersion>1 .0001</XpciVersion>" +
"</TransactionRefe rence>" +
"<RequestAction >Track</RequestAction>" +
"<RequestOption >activity</RequestOption></Request>" +
"<TrackingNumbe r>" + "1Z12345E029198 0793" + "</TrackingNumber> </TrackRequest>";
//WebProxy proxyObject = new WebProxy("http://wwwcie.ups.com: 8080");

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

HttpWebRequest myHttpWebReques t = (HttpWebRequest ) WebRequest.Crea te(url);
myHttpWebReques t.Credentials = new etworkCredentia l(UserName,User Password ); myHttpWebReques t.Method = "POST";
myHttpWebReques t.KeepAlive = false;
//myHttpWebReques t.Connection = "/ups.app/xml/track";
myHttpWebReques t.UserAgent = "Test XML Request";

myHttpWebReques t.ContentType = "applicatio n/x-www-form-urlencoded";

// Set the 'ContentLength' property of the WebRequest.
myHttpWebReques t.ContentLength = XmlRequest.Leng th;

Stream SendStream=myHt tpWebRequest.Ge tRequestStream( );

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

SendStream.Writ e(byteArray,0,b yteArray.Length );

HttpWebResponse WebResp = (HttpWebRespons e) myHttpWebReques t.GetResponse() ;
// Now read the data from response
//Get a readable stream from the server.
Stream RecvStream = WebResp.GetResp onseStream();

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.Clos e();
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
2037
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 source code tracking is extremely useful for recursive functions. I have spent time Googling but not found anything near. Thanks!
3
2810
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 product group for each customer. Hpw do I do this without creating a table for each customer and each product group with autonumbers. For example based on the entries in this sample, the desired result would be: Customer Business Unit Tracking...
2
2665
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 web based bug tracking application would you suggest me? best regards, gicio
6
2127
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
1721
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 clients. While for other clients user has to log into the website to download docs. We used to create dummy/fake accounts(in sql server) for client users who do not require login and use the created account to track recent downloads(using cookie...
1
16211
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 NUMBER HERE>&track.x=0&track.y=0 it will link you directly to the UPS tracking page for the specified tracking number. I think it would be really cool to be able to click a tracking number record in a table and have it take you directly to the...
3
2512
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 Runtime>.AddService(trackingService); trackingService.IsTransactional = false; trackingService.UseDefaultProfile = true; This works just fine.
0
1796
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. TimeLive is available in two different flavors. Hosted version and downloadable version. Downloadable version required certain system requirement to install on local server. Whereas hosted version is already installed on our fully managed server on...
5
2339
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 and I was given the tracking code and told I need to insert the variable names for the order total and sales id. But I have no idea what these are where to find them. The tracking code looks like this <img height="1" width="1"...
0
8878
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8785
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...
0
8644
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...
1
6200
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
5671
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4200
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...
1
2776
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2012
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1778
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.