Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > UPS Tracking

Reply
Thread Tools

UPS Tracking

 
 
=?Utf-8?B?SHR0cFdlYlJlcXVlc3Q=?=
Guest
Posts: n/a
 
      02-09-2004
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();
 
Reply With Quote
 
 
 
 
gary Vidal
Guest
Posts: n/a
 
      02-09-2004
The track is Case Sensitive Should be "Track"
"HttpWebRequest" <> wrote in message
news:03EABC6B-45AC-400D-A5A3-...
> 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();



 
Reply With Quote
 
 
 
 
gary Vidal
Guest
Posts: n/a
 
      02-09-2004
The track is Case Sensitive Should be "Track"

"HttpWebRequest" <> wrote in message
news:03EABC6B-45AC-400D-A5A3-...
> 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();



 
Reply With Quote
 
=?Utf-8?B?VmlzaG51IFN1bmthcmE=?=
Guest
Posts: n/a
 
      02-09-2004
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)
 
Reply With Quote
 
gary Vidal
Guest
Posts: n/a
 
      02-09-2004
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" <> wrote in message
news:03EABC6B-45AC-400D-A5A3-...
> 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();



 
Reply With Quote
 
=?Utf-8?B?VmlzaG51IFN1bmthcmE=?=
Guest
Posts: n/a
 
      02-10-2004
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
IP use Tracking bwillyerd@dshs.wa.gov Cisco 3 07-16-2005 05:13 PM
Cat Cam - Pet Tracking John Computer Information 31 10-22-2004 08:30 PM
Tracking IP Seth ASP .Net Web Services 2 03-04-2004 11:50 AM
tracking tommy Computer Support 1 01-05-2004 03:19 AM
What's this? tracking ? Rover Computer Support 2 09-23-2003 02:19 AM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57