Johnny posted on May 1, 2008 05:14

Almost two years ago I posted an article on CodeProject.com where I created a library that wrapped the USPS Web Tool API and exposed the functionality as a native .NET class library. You can find the original article here.

I have been working on a DHL and FedEX version and will be releasing them soon here at Johnny Can't Code. Stay tuned!


Posted in: Free Software , Source code  Tags:

Currently rated 5.0 by 3 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Related posts

Comments


us Lesley
May 1. 2008 12:46
Yay! I saw your blog show up in my RSS feeds today and got all excited. Loving all your posts!

That is all. Smile Hope you are doing well.




fr Laurent
May 3. 2008 16:10
Hi Smile
I've just seen your article on CodeProject, congratulations for your work, even if it's not really useful for me in Europe ;) But I'd be very interested to see how you created a library to communicate with DHL and Fedex as I had to do that too a few months ago (and for UPS also).
Can't wait to see your code ^^

Cheers.
Laurent




in Prabhat
June 2. 2008 04:48
Hi There,

I have downloaded your USPS source code from Codeproject for USPS web wrapper tool, but i am not able to test it properly can you provide me how you are generating the USPS shipping label. Also do you have any idea how we can generate the UPS shipping label using ASP.NET. do you have any sample code or link where i can see that how they are creating.

Thanks & Regards
Prabhat




us Tony G
June 30. 2008 17:42
Hiya Scott. Working on a similar project I just downloaded and started tinkering with your USPS code. I was going to write everything from scratch just as a matter of principal, but you've done a fine job with this as a place for anyone to start.

Just an FYI, I've added some code to Address.FromXml(string xml). The reason will be obvious. HTH, and thank you very much. element = doc.SelectSingleNode("/CityStateLookupResponse/ZipCode/Zip5");
if ( element != null )
a._Zip = element.InnerText;
element = doc.SelectSingleNode("/CityStateLookupResponse/ZipCode/City");
if ( element != null )
a._City = element.InnerText;
element = doc.SelectSingleNode("/CityStateLookupResponse/ZipCode/State");
if ( element != null )
a._State = element.InnerText;


element = doc.SelectSingleNode("/ZipCodeLookupResponse/Address/Address1");
if ( element != null )
a._Address1 = element.InnerText;
element = doc.SelectSingleNode("/ZipCodeLookupResponse/Address/Address2");
if ( element != null )
a._Address2 = element.InnerText;
element = doc.SelectSingleNode("/ZipCodeLookupResponse/Address/City");
if ( element != null )
a._City = element.InnerText;
element = doc.SelectSingleNode("/ZipCodeLookupResponse/Address/State");
if ( element != null )
a._State = element.InnerText;
element = doc.SelectSingleNode("/ZipCodeLookupResponse/Address/Zip5");
if ( element != null )
a._Zip = element.InnerText;
element = doc.SelectSingleNode("/ZipCodeLookupResponse/Address/Zip4");
if ( element != null )
a._ZipPlus4 = element.InnerText;
Also, I got a little tired of random failures from the USPS servers, at least during testing, so I've modified the routines in the USPSManager as follows: string addressxml = "";

for ( int i = 0 ; i < 3 ; i++ )
{
addressxml = web.DownloadString(url);
if ( addressxml.Contains("<Error>") )
{
// try a few times in case there is a flukey error
if ( i >= 2 ||
addressxml.IndexOf("<Number>80040b1a</Number>") > -1 || // authorization failure
addressxml.IndexOf("<Number>-2147219040</Number>") > -1 // data not on test server
)
{
int idx1 = addressxml.IndexOf("<Description>") + 13;
int idx2 = addressxml.IndexOf("</Description>");
int l = addressxml.Length;
string errDesc = addressxml.Substring(idx1 , idx2 - idx1);
throw new USPSManagerException(errDesc);
}
else
{
System.Threading.Thread.Sleep(250);
}
}
}
That allows it to pause and retry a couple times just to make sure errors are real. Finally, unless you know a reason why not, I'm going to externalize the error messages passed through USPSManagerException. Someone might want to localize the hardcoded English text, and I feel a need to lookup and verify the character limits placed on address and city fields. Some addresses simply won't fit those fields and it wouldn't be good form to exclude some data from cleansing just because someone has a large address or some municipality doesn't fit the arbitrary limits.

Regards.




us Jupi
September 12. 2008 13:20
Scott I just came across this "USPS Web Tools Wrapper". I tried downloading the source code from code project but some of the files are having some problem. Can you please send me the source code if possible. i would really appreciate it.

Thanks,

Jupi




in sunny
September 25. 2008 04:50
when are you going to post ur dhl and fedex code...and plz put a paypal button for voluntary contribution. We love you ! thx




September 13. 2009 19:39
Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts.Any way Ill be subscribing to your feed and I hope you post again soon

http://www.easyfaxlesspaydayloan.com/


October 14. 2009 05:52

I recently came across your blog and have been reading along. I thought I would leave my first comment. I don't know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often.

http://outdoorfireplacesok.com/


November 23. 2009 15:55
It seems that you have really put a good amount of effort into your blog and I require much more of these on the Internet these days. Me and my husband thoroughly loved your post. I don't really have much to say in reply, I only wanted to add this comment to reply well done.

http://www.zimbio.com/Jaycee+Lee+Dugard/articles/m5iz3oAuk7f/Concord+Marriage+Records

Search Blog Post

Follow me on

Twitter Updates

    Recent Comments

    Disclaimer
    The opinions expressed herein are my own personal opinions.

    © Copyright 2010 Johnny Can't Code