A Day in the Life

A day in my life. Thoughts on leadership, management, startups, technology, software, concurrent development, etc... Basically the stuff I think about from 10am to 6pm.

2/14/2006

Software: Web Service for Beginners

I just finished Digipede-enabling a web service so that we would have a working sample of a web service use case. I have bigger plans for Digipede behind a web service but I have to start somewhere and the first place to start is with learning the technology. So I started with a simple Monte Carlo Pi web service. (I should have probably started with Hello World, but I’m a little over confident.)

Creating a web service and testing it was extremely straight forward. This was quite a surprise. I was able to get everything up Monday morning between 3am and 4am. (Sometimes I can’t sleep...what can I say?)

I used a MonteCarloPiLibrary DLL (which contains the Monte Carlo Pi algorithm) that I have hanging around from other projects and wrapped a web service around that. I created a web service function double GetPi(int numTasks, int numDraws).

The web service acts as a Master application so I wrote the 20 lines of code needed to create the Tasks and distribute the work. But I was having problems. I would send the work out to the Digipede Server but my call to WaitForJob() was not returning. I finally figured out today that I don’t need the RaiseEventsOnCallingThread set to true. Removing the RaiseEventsOnCallingThread property fixed my problem.

Here are a few things I learned:

- I created a console application (TestWS) that made a call to the web service. It took me a little while to figure out that to access the web service class I had to do Add Web Reference and add the web service to the TestWS project. It’s strange to access a type that isn’t clearly defined in the code. Here is the code for TestWS:

static void Main(string[] args) {

// Get Pi
localhost.MonteCarloPiService myService = new localhost.MonteCarloPiService();
double piRet = myService.GetPi(1, 1000);
Console.WriteLine("piRet = {0}", piRet);
Console.ReadKey();
}


I don’t have a clear understanding of localhost yet (as defined in the code above); it looks like the text can be whatever you want. This clearly becomes one of those things you want to have a good naming convention for.

- When debugging TestWS I had to step into the web service. When I set a breakpoint in the web the debugger didn’t stop. So set your break on the web service call and then step in.

- If you get the VS2005 error message, “Unable to automatically step into the server. The remote procedure could not be debugged...”. You need to change the web.config file on the web service so that the tag property is set to true. <compilation debug=”true”>. Thanks Harish.

- I didn’t need to create a test console application because running the web service with the VS2005 provided starting page would have stopped program execution at a breakpoint in the web service. But I when I first tried that I didn’t have the compilation property in web.config set correctly. This was not clear when I started so I did what everyone does and fell back to the stuff I know.


I did this initial development with a Digipede Server and Agent all installed on my laptop. Basically a closed system. Once I got it working I changed the login information and told the application to run against Digipede’s main testing Server. The only code I changed was the login information and my test application worked the first time without any other changes. That was cool.

I’ve still got some work to do to make this sample look nice but creating my first web service and Digipede-enabling it was a much shorter project than I expected. I should also add that it’s been years since I did any ASP work and I’ve never done any ASP.NET work. Microsoft has done a great job with the new VS2005.

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home