Beska
Beska

Reputation: 12667

How can I debug this web service?

I have a simple web service that looks something like this:

[WebMethod]
public OrderForecastItem GetOrderForecast(int shipTo, string catalogName, bool showPricing)
{ 
    return OrderForecastManager.GetOrderForecast(shipTo, catalogName, showPricing);
}

I'm calling it from another place in a fairly simple way:

using (OrderForecastWS.OrderForecastWS service = new OurSite.Web.Reporting.OrderForecastWS.OrderForecastWS())
{
    OrderForecastItem orderForecastItems = service.GetOrderForecast(2585432, "DENTAL", false);
}

After some gymnastics to get the systems to understand that I'm talking about the same type of objects on the client and server sides (I had to open the Reference.cs file inside my Web References, delete the generated OrderForecastItem and add a link to our real OrderForecastItem), the system runs and attempts to get the item.

Unfortunately, it now bombs during the service call, claiming:

Exception There is an error in XML document (1, 1113).(InvalidOperationException)

I can go to the web service in a browser, put in the same values, and I get a seemingly valid XML response. (It looks okay to me, and I ran it through the XML parser at W3Schools, and it cleared it.)

I think the numbers in the error are supposed to be the line and character number...but the browser seems to reformat the xml document, so I can't easily see what the original (1, 1113) location is.

I don't see an easy way to intercept the response and examine it, since it seems to be blowing up as soon as it gets it.

How can I debug this?

Upvotes: 3

Views: 1065

Answers (2)

Val Bakhtin
Val Bakhtin

Reputation: 1464

If you control the service, you can step into it. If it is a part of your solution and hosted in VS WebDev on your local box, just F11 from Visual Studio, if service is hosted remotely (eg by IIS on other computer) run remote debugging tool on service host msdn, and then you will be able to step in to the service remotely.

By the way, you can tell Visual Studio to re-use objects from referenced libraries for types from the service: just pick configure Service Reference from service context menu and tell which libraries to re-use.

On second thought this error may happen if returned XML could not be deserialized into your business object. May happen when class is changed on either side, or you are trying to use different version of business library than service is using.

Upvotes: 3

brazilianldsjaguar
brazilianldsjaguar

Reputation: 1449

If you use Firefox, I'd recommend Firebug. You'll be able to easily view the response from the website in its original format, which might get you closer to the line and position you're looking for.

Upvotes: 1

Related Questions