Thursday, March 15, 2007

Web Service Enhancements 3.0

For the last couple of days I've been attempting to communicate with an external Web Service that I need to use Web Service Enhancements for. Particularly I needed to set the value of a UsernameToken within the header.

I found a codeproject article on it (WS-Security: Secure Web services through SOAP Message Level Security) on which I based the code, and this did work. I eventually got successful responses when I had figured out the right format of parameter to use.

However, the codeproject article was written for WSE 2.0, and I was using WSE 3.0. The Security property on RequestSoapContext is rather annoyingly marked as Obsolete in WSE 3.0, and I was using this to set the required header.

Eventually I found the rather snappily titled article Custom WSE 3.0 Policy Assertions for Signing and Encrypting SOAP Messages with Username Tokens on codeproject again. From this I found I had to replace my 1 line of client code with 2 separate classes, and 4 additional lines within the client code.

I have no idea why the propery is now Obsolete, but the new way of doing the same thing was much too difficult to find in my opinion.

No comments: