Why Web Services Are Easy To Love & Hate

This article was written with the intention of Improving the Web Service Development Experience particularly in the areas of Testing & Debugging.

 

The  specific topics discussed in this article include: 

  • Identify common developer challenges with web service development.
  • Offer suggestions on how to  improve the development experience.
  • Instructions on how to easily debug your PowerBuilder developed WCF Web Service.
  • How to use the Microsoft WCF Test Client to easily test your web services.

Web Services, a thorn in the developers’ side

Let me start out by clarifying how I feel about web services in general.  I think all web services suck no matter what flavor they are or tool they were developed with.  I really like to use web services as a data source to my applications and web sites, in fact I would rather use a web service than a direct database connection.

If you are thinking, “What the hell is he talking about that didn’t clarify anything?”, then I’d say you hit the nail on the head!  If you perceived a certain negative attitude or “tone” in my words you were spot on, and it means I was successful in putting my true feelings about this love & hate relationship into words.

Web Service development is boring

The development process for Web Services is not really that much fun compared to other development tasks.  With user-interface development you get the instant gratification of tangible results in a short amount of time.

The good news is that web services are starting to become more fun to develop thanks in part to Microsoft.  Microsoft has hidden much of the ugly plumbing for WCF Web Services and they have made calling web services simple via an ASP.NET API.

Quick & Dirty WCF Web Service Testing

Coding the web services wasn’t so difficult, but getting them to work takes something just short of a miracle.   Again, this has improved thanks to industry standards but getting a web service working under IIS and accessible to the world while maintaining a secure environment is still a small challenge.

WCF Test Client - Web Service TesterBefore I learned of the Microsoft WCF Test Client application there really wasn’t an easy way to test web services.  Testing usually involved writing some type of shell program.

The Microsoft WCF Test Client makes testing a whole lot easier.  You “open” an web service and pull in all the available methods, you can set input parameters and invoke the web service, and you can view the results in formatted or XML output.

The GUI tool comes standard with Visual Studio 2008 and is called WCF Test Client, you can find more information here about how to use the tool.

 

How to Debug PowerBuilder 12.5.NET WCF Web Services

Debugging a WCF Web Service is not that much different than debugging a standard PowerBuilder application.  The main difference with debugging the web service is that you don’t just “Run” the web service like you do a typical PB program.  You will start the WCF Test Client first, and then start the debug.

The reason that you want to start the WCF Test Client is that PowerBuilder needs to “bind” to the process that is running the web service upon starting the debug process.

Steps for Debugging a PowerBuilder 12.5.NET WCF Web Service

1. Compile WCF Web Service in PB12.5.NET (with DEBUG option in project painter)

Enable Debug PB WCF Web Service

Enable Debug PB WCF Web Service

2. Deploy the web service and make a note of the web service URL, it will be needed in the test client.

Enable Debug PB WCF Web Service

3. Open the WCF Test Client and Open the Web Service within the WCF Test Client

Enable Debug PB WCF Web Service

4.  Set your PowerBuilder debug breakpoints like you normally do.

5. Initiate Debug the WCF Web Service in PowerBuilder (Alt + F5) – Your break point will likely not be reached until later after we invoke a web service.

6. Allow the PB Debugger to Attach to the WCF Test Client by accepting the Security Warning.  Click “Attach”

Enable Debug PB WCF Web Service

7. Double click a web service method to test, and click Invoke.  Here, I clicked on GetCategory which takes one integer argument. I entered the argument value 14.

Enable Debug PB WCF Web Service

8.  If all goes well, PowerBuilder 12.5.NET will come to the front (or flash in your taskbar) when a breakpoint has been reached. You can step through code like you normally do.

note: if you take some time debugging you may get an error from the test client because it will think the web service has not responded in a reasonable amount of time.   You can ignore it and continue debugging.

Summary – Testing & Debugging of WCF Web Services

Use the Microsoft WCF Test Client to test your web services.  Use the same tool to invoke web services that will cause breakpoints to be reached in your PowerBuilder code, and allow you to debug the code.  By using the test client and debugger you can get through the worst part of development quickly!

Similar Articles

PowerBuilder WCF Web Service consumed by ASP.NET MVC web site.  This is a full blown example from start to finish using a simpler self-hosted web service rather than an IIS hosted web service.  This three page article covers all steps in creating a  WCF Web Service, consuming the web service via ASP.NET MVC, and includes source files for download.

Entry Level PowerBuilder WCF Web Services –  This is also a full blown example from start to finish but it focuses mostly on the actual web service and has very little on the consumption of the web service.  This is a good first time article for WCF Web Services.

Tags:

One response

Leave a Reply

Your email address will not be published. Required fields are marked *