473,388 Members | 1,400 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,388 software developers and data experts.

UPS Online Tools

OK, this is going to be a lengthy post with a lot of code. I have built a
class library in C# for communicating with UPS' online tools for package
tracking, time in transit and a few other services. I have used
serialization to form the requests and I use deserialization to read the
responses. The code for Rates and Services works beautifully but the Time in
transit deserialization states that there is no root element in the XML that
UPS kicks back. The deserialization method for the response was copied from
the working Rates and Rervices response with the only modification being the
type passed to the XmlSerializer constructor. Any Ideas? code listed below:
XML Request from Serialized object(s):
--------------------------------------
<?xml version="1.0" encoding="utf-16"?>
<AccessRequest xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xml:lang="en-US">
<AccessLicenseNumber>9BE571A78CC539A8</AccessLicenseNumber>
<UserId>ApolloDesignTech</UserId>
<Password>upsgbjyd</Password>
</AccessRequest>
<?xml version="1.0" encoding="utf-16"?>
<TimeInTransitRequest xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xml:lang="en-US">
<Request>
<TransactionReference>
<CustomerContext>TNT_D Origin Country Code</CustomerContext>
<XpciVersion>1.0002</XpciVersion>
</TransactionReference>
<RequestAction>TimeInTransit</RequestAction>
<RequestOption />
</Request>
<TransitFrom>
<AddressArtifactFormat>
<PoliticalDivision2>LONDON</PoliticalDivision2>
<PoliticalDivision1>CITY OF LONDON</PoliticalDivision1>
<Country />
<CountryCode>GB</CountryCode>
<PostcodePrimaryLow>EC03</PostcodePrimaryLow>
</AddressArtifactFormat>
</TransitFrom>
<TransitTo>
<AddressArtifactFormat>
<PoliticalDivision2>NASSAU</PoliticalDivision2>
<PoliticalDivision1 />
<Country />
<CountryCode>BS</CountryCode>
<PostcodePrimaryLow />
</AddressArtifactFormat>
</TransitTo>
<ShipmentWeight>
<UnitOfMeasurement>
<Code>KGS</Code>
<Description>Kilograms</Description>
</UnitOfMeasurement>
<Weight>23</Weight>
</ShipmentWeight>
<TotalPackagesInShipment>123</TotalPackagesInShipment>
<InvoiceLineTotal>
<CurrencyCode>USD</CurrencyCode>
<MonetaryValue>250</MonetaryValue>
</InvoiceLineTotal>
<PickupDate>20060309</PickupDate>
<DocumentsOnlyIndicator />
</TimeInTransitRequest>
Raw XML Response from UPS.com
--------------------------------------
<?xml version="1.0"?>
<TimeInTransitResponse>
<Response>
<TransactionReference>
<CustomerContext>TNT_D Origin Country Code</CustomerContext>
<XpciVersion>1.0002</XpciVersion>
</TransactionReference>
<ResponseStatusCode>1</ResponseStatusCode>
<ResponseStatusDescription>Success</ResponseStatusDescription>
</Response>
<TransitResponse>
<PickupDate>2006-03-15</PickupDate>
<TransitFrom>
<AddressArtifactFormat>
<PoliticalDivision2>LONDON</PoliticalDivision2>
<PoliticalDivision1>CITY OF LONDON</PoliticalDivision1>
<Country>UNITED KINGDOM</Country>
<CountryCode>GB</CountryCode>
<PostcodePrimaryLow>EC03</PostcodePrimaryLow>
</AddressArtifactFormat>
</TransitFrom>
<TransitTo>
<AddressArtifactFormat>
<PoliticalDivision2>NASSAU</PoliticalDivision2>
<Country>BAHAMAS</Country>
<CountryCode>BS</CountryCode>
</AddressArtifactFormat>
</TransitTo>
<DocumentsOnlyIndicator></DocumentsOnlyIndicator>
<AutoDutyCode>02</AutoDutyCode>
<ShipmentWeight>
<UnitOfMeasurement>
<Code>KGS</Code>
</UnitOfMeasurement>
<Weight>0.2</Weight>
</ShipmentWeight>
<InvoiceLineTotal>
<CurrencyCode>USD</CurrencyCode>
<MonetaryValue>250.00</MonetaryValue>
</InvoiceLineTotal>
<Disclaimer>Services listed as guaranteed are backed by a money-back
guarantee for transportation charges only. See Terms and Conditions in the
Service Guide for details. Certain commodities and high value shipments may
require additional transit time for customs clearance.</Disclaimer>
<ServiceSummary>
<Service>
<Code>11</Code>
<Description>UPS Express NA1</Description>
</Service>
<Guaranteed>
<Code>Y</Code>
</Guaranteed>
<EstimatedArrival>
<BusinessTransitDays>1</BusinessTransitDays>
<Time>23:30:00</Time>
<PickupDate>2006-03-15</PickupDate>
<PickupTime>16:00:00</PickupTime>
<HolidayCount>0</HolidayCount>
<DelayCount>0</DelayCount>
<Date>2006-03-16</Date>
<DayOfWeek>THU</DayOfWeek>
<TotalTransitDays>1</TotalTransitDays>
<CustomerCenterCutoff>15:00:00</CustomerCenterCutoff>
<RestDays>0</RestDays>
</EstimatedArrival>
</ServiceSummary>
<ServiceSummary>
<Service>
<Code>01</Code>
<Description>UPS Worldwide Express</Description>
</Service>
<Guaranteed>
<Code>Y</Code>
</Guaranteed>
<EstimatedArrival>
<BusinessTransitDays>2</BusinessTransitDays>
<Time>23:30:00</Time>
<PickupDate>2006-03-15</PickupDate>
<PickupTime>19:00:00</PickupTime>
<HolidayCount>0</HolidayCount>
<DelayCount>0</DelayCount>
<Date>2006-03-17</Date>
<DayOfWeek>FRI</DayOfWeek>
<TotalTransitDays>2</TotalTransitDays>
<CustomerCenterCutoff>18:30:00</CustomerCenterCutoff>
<RestDays>0</RestDays>
</EstimatedArrival>
</ServiceSummary>
<MaximumListSize>35</MaximumListSize>
</TransitResponse>
</TimeInTransitResponse>
Deserialization Method of the TimeInTransitResponse object
--------------------------------------
public void Deserialize ( System.IO.Stream xmlResponseStream )
{

// Local Variables
TimeInTransitResponse r = null;
XmlSerializer xs = new XmlSerializer(typeof(TimeInTransitResponse));

// Begin

try
{

r = new TimeInTransitResponse();
r = (TimeInTransitResponse) xs.Deserialize(xmlResponseStream);

this.Response = r.Response;
this.TransitResponse = r.TransitResponse;

}// end try
catch ( Exception appEx )
{

this.DeserializeException = appEx;

}// end catch
finally
{

xmlResponseStream.Close();

}// end finally
}// end Deserialize
Exception:
--------------------------------------
System.InvalidOperationException: There is an error in XML document (0,
0). ---> System.Xml.XmlException: The root element is missing.
at System.Xml.XmlTextReader.Read()
at System.Xml.XmlReader.MoveToContent()
at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read13_TimeInTransitResponse()
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader
xmlReader, String encodingStyle, XmlDeserializationEvents events)
at System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader
xmlReader, XmlDeserializationEvents events)
at System.Xml.Serialization.XmlSerializer.Deserialize (Stream stream)
at
ApolloDesignTechnology.Shipping.Ups.TimeInTransit. TimeInTransitResponse.Deserialize(Stream
xmlResponseStream)
--
Grant Harmeyer
Mar 14 '06 #1
2 4178
Would it be possible to see the TimeInTransitResponse Class and all the
relevant classes used in the Deserialise process of
TimeInTransitResponse

Mar 15 '06 #2

Grant could you send me your work, I am working on a similar project.
Please let me know and I will pass on my email.

--
samstraub
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------

Apr 6 '06 #3

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

Similar topics

9
by: David | last post by:
I am setting up a web community with a feature that will display whether or not a member is currently online. I intend on implementing this by holding a column in the dbase simply called online....
2
by: Mario | last post by:
Hi, I'm experiencing a nasty problem with Visual Studio .Net 2003. Most Online Resources in the Start Page doesnt work, showing the following message: "This feature requires that you have...
21
by: Paulb1us | last post by:
In VS .net 2003 There is a online resources tab on the start page. When I click the links such as headlines, downloads or xml services I get a message stating that this feature requires a...
0
by: Lior Bobrov | last post by:
Hello . I now have Visual Studio 2005 Common Technology Preview (CTP) February 2005 with no MSDN . I try to use the MSDN Online from within the IDE , as follows : In the IDE , I click...
2
by: shank | last post by:
Has anyone ever set up code samples for using UPS online tools? I need it for international shipping. I've been trying to setup the tools myself. Some countries work fine, others produce validation...
1
by: Ken VdB | last post by:
Hi everyone, I am trying to integrate UPS's Online Tools into my classic ASP project. Does anyone have some examples of this that I could look at? I am specifically looking for information on...
9
by: Daven Thrice | last post by:
If I have a fairly big Access MDB, that is relational, and has, say, 100 objects (forms, reports, modules, etc.), what is the path to get this database "online". Is there a way to put the tables...
1
by: dan heskett | last post by:
Hello group, I have been making a measured but successful transition from a number of development platforms to NET/VB.NET over the last year or so. One thing I've yet to get into is online or...
0
by: raylopez99 | last post by:
10 years ago, the below was written (see very end, after my signature RL). What, if anything, has changed? I have Access 2003 and soon Access 2007 on a Windows XP Professional or Windows...
15
by: dreen1 | last post by:
Hello! Does any one of you know about some kind of PHP IDE (or at least an editor with syntax highlighting) that works online? It would be absolutely great if there was something like Google...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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
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...

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.