Tim Burns' Weblog
 
Friday, October 24, 2003 [*]
 

I can't believe how easy they make it for me

I had an "oh my god I can't believe it's this easy" moment today when I deployed my first web service to C# from Java. I started off with my standard bare-bones J2EE server and in the Visual Studio environment. Being an XP guy, I wrote my test first with nUnit.
    using System;
    using NUnit.Framework;
    
    namespace Simple
    {
    	[TestFixture] public class SoapClientTest : Assertion  
    	{
    		private SoapClient client;
    
    		[Test] public void EchoMessage() 
    		{
    			this.client = new SoapClient();
    			AssertEquals("Hello world", client.echoHeader("Hello world"));
    		}
    	}
    }
    
To make the test work, all I had to do was select Project->Add Web Reference and then enter in the WSDL reference to my web service. When I added in the echo service (http://localhost:8080/axis/EchoHeaders.jws?wsdl) that comes with Axis, it generated the objects for me. How cool is that? Here is the code:
    using System;
    
    namespace Simple
    {
    	public class SoapClient
    	{
    		Simple.localhost.EchoHeadersService echoHeaderService = null;
    
    		public SoapClient()
    		{		
    			echoHeaderService = new Simple.localhost.EchoHeadersService();
    		}
    
    		public string echoHeader(string message) 
    		{		
    			return echoHeaderService.echo(message);
    		}
    
    	}
    }
    
Before getting to work, however, my google searches turned up a lot of crap examples. The only one that was useful was Developing a .Net client to interact with a WebSphere Web service. Most of it had to do with trying create a web service without using WDSL, and I guess that is understandable. Basically, if you need to look at MSDN or any documentation, you are doing it wrong. I've added the C# source into my simple template code.
 
Comments [0]
 
xml

Articles

Non-Blocking Socket I/O in JDK 1.4

Generating Entity Beans with XSL Templates

 

Photos

Phantom Farms
Providence
Baby Shower
Camden, Maine
 

The Daily Chronic

Atrios
Bio Informatics
Brown News
Carl Zimmer
Charles Murtaugh
Dijkstra
Docnotes
Get Fuzzy
Oreilly
Pipeline
Philip Greenspun
Orcinus
Salon
Science Blog
Scientific American
The Living Code
Tom Tomorrow
Woods Hole News
 

References

BioInformatics

Epicurious

Statistics

 

Archive

2003
 November 02 23
 October 07 11 12 16 18 21 24 26
 September 04 09 10 12 14 28
 August 05 08 13 17 18 25 29
 July
 June
2002
2001
 
Copyright 2001-2003 Owl Mountain Software, LLC