views:

23

answers:

2

I created a web service on localhost, and I tried to call it from a web app (also on the localhost) via HttpWebRequest, but Application_BeginRequest in Global.asax didn't fire. When I type in IE 'http://localhost:8010/Test/' (the web service) Application_BeginRequest fires. Where is the problem? How can I test a localhost web service from a page which is also on localhost?

A: 

Not sure if you have a WCF web service or not, but if you do check out, "WCF Services and ASP.NET". WCF services aren't handled by IIS in the same way as web sites are, which may be the reason BeginRequest doesn't get hit:

The ASP.NET HTTP runtime handles ASP.NET requests but does not participate in the processing of requests destined for WCF services, even though these services are hosted in the same AppDomain as is the ASP.NET content. Instead, the WCF Service Model intercepts messages addressed to WCF services and routes them through the WCF transport/channel stack.

Mike Comstock
A: 

Generally, the best way to test a web service is to write a client to consume it. In particular, you can use a unit test framework to write automated tests of the service.

WCF doesn't even offer the web pages that allow you to test a service, BTW.

John Saunders