.NET and Java WebService
Sometimes one does things just to see the result. In this case I wanted to see how it would be to access a Java web service from a .NET C# application. The client side of GRITS project uses VTK along with QT. While there are .NET wrappers for VTK I haven’t tried them. Besides the QT/VTK combination works on Apple as well so .NET wouldn’t bring anything to the table. But I still wanted to see. The WebService is running on a JBOSS Application server with Apache as the Web server. Hibernate provides the object/relational persistence and query service.
I am using VS 2008 and its fairly straight forward.
The first step is to create a new ASP.NET web site.
The second step is to add a Web Reference.
On the Web Reference screen enter the url of the web service wsdl.
After the processing is done you can see a list of services that were found. So far this is exactly what I was hoping for.
The next step is to add code that will connect to the service. Since we named the service Grits we can do the following.
using Grits; // add name space
public partial class _Default : System.Web.UI.Page
{
GritsWebService proxy; // create a service proxy variable
protected void Page_Load(object sender, EventArgs e)
{
proxy = new GritsWebService();
}
And finally call the service. At this point nothing will happen. Watching the JBOSS console window shows no activity.One query that I know will work with out VTK is “findRegionByExtent”. This call takes a user name and six points that will define a bounding volume.
Selecting “GritsWebService” and then “Go to Definition” gives a list of all of the functions along with their parameters and return values.
The function “findRegionByExtent” takes a “findRegionByExtent” type as a calling parameter and returns an “areaRegionInformation” array.
Using “Go to Definition” we can see how they are constructed.
The “findRegionByExtent” type isn’t very descriptive, its just indicates seven args. I’ll need to address this on the Web service side so that it uses more descriptive values. Since I created the beast I know that arg0 is the user name and args 1-6 are xmin,xmax,ymin,ymax,zmin and zmax. These describe the volume in which we want to search.
The return value “areaRegionInformation” returns a set consisting of genename, spotname, stagename and a set of points. There will be one set for each unique gene,spot,stage combination that lies within the bounding volume.
Here is the code that sets up and makes the call. I added six points that I know will provide results.
Running the app in the VS debugger I see a response in the JBoss console window indicating that two “spots’ were located:
INFO [STDOUT] xmin -70.33 xmax -50.33 ymin 62.93 ymax 82.93 zmin -144.03 zmax -122.03
INFO [STDOUT] findRegionByExtent– The number returned is :2
In the VS debugger with a break point set we can see the results(part of them) returned from the service.The length of the array “test” is 2 and the first genename is “Calbindn” so I know that is working.
The next step would be to display this results. This would require the .NET version of VTK, maybe later but I wonder about the iPhone…..?














