Skip to content

MikeBevers.be

Putting it out there…

Archive

Tag: WCF

Context

Before WCF, there was ASMX aka ASP.NET Web Services. Debugging ASMX or WCF are quite different. Let’s take a look how we can enable debugging in ASMX and WCF.

Basics of running a web application

When you hit the F5 button and your startup project is an ASP.NET, ASP.NET Web Services or WCF application, Visual Studio will start an ASP.NET Development Server. This is what we call Client-side hosting using Cassini. If want to know more check Dino Esposito’s article on MSDN. Wikipedia also has a description about UltiDev Cassini Web Server.

After Cassini is loaded, by default an Internet Explorer (IE) window will open and browse to the Cassini URL on your localhost.

Debugging ASMX

When you hit the F5 button, IE will open a webpage which looks like the image below:

Browse ASP.NET Web Service

Browse ASP.NET Web Service

You’ll notice that all Web Methods are listed as hyperlinks. So when I click “HelloWorld” in my example, it will browse forward:

Invoke ASP.NET Web Service

Invoke ASP.NET Web Service

Before we invoke the Web Method using IE, first we need to attach the Visual Studio instance with our sources to Cassini! In Visual Studio, navigate to “Debug” > “Attach to Process …”. In the list of Available Processes there should be a process called “WebDev.WebServer.exe” and the Title should be “ASP.NET Development Server – Port XXXX”. The Port XXXX is the port on which Cassini is active. Click the “Attach” button and you are ready to go!

Now, click the button “Invoke” in Internet Explorer and your Visual Studio will stop at the first breakpoint it encounters. When the method has returned its result, a new IE window will open and display the result as XML, like below:

ASP.NET Web Service Result

ASP.NET Web Service Result

 

Debugging WCF

Like ASMX, Visual Studio will open a browser by default:

Browse WCF Service

Browse WCF Service

At first it shows the directory listing. When you open your Service1.svc, you’ll notice that no hyperlinks or Invoke buttons are available on our Operation Contracts. To debug the WCF service, Microsoft provided a small tool in your Visual Studio installation directory, called “wcfTestClient.exe”. The tool is usually located in “C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\wcfTestClient.exe”. If not, you can download and install the Windows SDK from the Microsoft website.

In order to automatically start the “wcfTestClient.exe” and load our Services, we need to edit the WCF application project:

Start wcfTestClient.exe

Start wcfTestClient.exe

You can add multiple svc’s by leaving a space between the addresses.

When your WCF Service is loaded, you can double click an Operation Contract and invoke it. You don’t need to attach your Visual Studio to another process, it’s already attached for you.

wcfTestClient Method Invokation

wcfTestClient Method Invokation

The Problem

When I’m in the office, I have to use an authenticated proxy to get outside our intranet and to the internet. When I called a service that resides on the web, I got the 407 error. How can we fix this without having to provide an account to our application?

continue reading…