Darrell Hawley: Home Page

Tuesday, October 10, 2006

WSE: Consuming the Service

I created a little application that takes a username and password and then calls the "Hello WSE" webservice I created. For comparison sake I created a method for calling a basic, unsecured webservice using the following code in a button click:


MyWebService.Service service = new Client.MyWebService.Service();
this.Message.Text = service.HelloWorld();


But we want the "WSE way", for crying out loud! As you can see, the amount of additional code required is minimal.


MyWebService.ServiceWse proxy = new Client.MyWebService.ServiceWse();
UsernameToken token = new UsernameToken(this.User.Text, this.Password.Text,
PasswordOption.SendPlainText);
proxy.SetClientCredential(token);
proxy.SetPolicy("MyPolicy");
this.Message.Text = proxy.HelloWSE();


Probably the most complex bit of this code is knowing - I wouldn't even call it understanding - where that ServiceWse() object came from. It was autogenerated! For every WebService you create, an associated "Wse" method (Web Service name with "Wse" appended to it) is generated when you use the WSE Wizard (say that 5 times fast).

That wraps it for the basic WSE stuff. You have a client, a server and the two can communicate using WSE. But are you secure? NO! What I have outlined in this series of posts allows you to send cleartext messages between client and server within the confines of WSE. Now we have to consider encryption before releasing this to this wild.

One last note, I'm going to create a new solution and build a webservice and client from scratch to make sure that the I have covered everything. I'm also worried about a couple of errors that I have run into along the way. My next post is going to cover an error (maybe two) and confirm that, yes, if you follow my directions, WSE will work.

OK. I have another last note. GO TIGERS!!! This life-long Cleveland fan is pulling hard for you.

0 Comments:

Post a Comment

<< Home