views:

213

answers:

3

I bought an ASP.NET script about a year ago to retrieve FedEx shipping values. It builds an XML string that passes to the FedEx server using an HttpWebRequest, then parses the raw XML. The average response time for the script is about 900 milliseconds.

So the other day I was poking around in the FedEx developer center and discovered that they provide some C# code samples for using their web service. I built a little project using their code and WSDL file, and was surprised to find that the average response time is about 2.5 seconds.

Can someone help me understand the difference in speed? And is there a way to make it faster? I have zero experience using web services.

Thanks.

+1  A: 

Web Services have some overhead with respect to XML over HTTP calls because of validation and what is called the "SOAP envelope", which adds some extra verbosity.

That said, I don't think the bigger response time is due to that. Did you try running the XML over HTTP version today to have a reasonable comparison point? Maybe the site is just busy.

One other explanation could be bad coding. You never know.

Sklivvz
+1  A: 

Well, the ASP.NET script could be doing something different than the C# code. Try capturing each raw HTTP request and playing them back. Do they perform the same? If so, then it is likely differences in the client code. My guess is that one is a straight HTTP get/post request, the other SOAP over HTTP(s).

Other things to look at: 1) Are you hitting production for ASP.NET and test system for C#, or are they both production? 2) Assuming both are over HTTPS.

A SOAP-based web service is typically a little more "heavy weight" -- especially if your request ends up doing WS-*, signing, etc. Do you have to sign your C# request by providing keys/x.509 or other credentials?

There are many ways this discussion could go depending on answers to a few of the basics above.

Dustin
"My guess is that one is a straight HTTP get/post request, the other SOAP over HTTP(s)."You're exactly right here. I've tested both over several days, and I'm hitting production servers for each. And yes, the SOAP call does require keys.
If you have control over the protocol, switch it to HTTP and catch the request using WireShark (or my fav, netcat). Play them back to the FedEx server and see what timings you get. I'd bet that most of the time in the SOAP service is due to SOAP + WS-* overhead.
Dustin
A: 

It seems likely that you will have to post some code to get an answer that will help you.

Sam