Wednesday, December 21, 2011

Technical Jargons

Web 2.0
Web 2.0
*******************************
Cloud Computing
Clud Computing

Wednesday, December 7, 2011

Using xmlhttp to POST soap request for WSE 3.0 enabled Webservice


Consider a situation,
You have a WSE 3 enabled Webservice(developed in dotnet) and you have to access that without creating PROXY.

We can do this by creating XMLHTTP object and then construct SOAP request

But the problem is in creating the proper request with valid Authentication header. Many times we will end up creating invalid request mostly invalid authentication headers

But there is a easy way. Two tools comes handy for us to implement and test this.
1) Fiddler for creating request
2) SOAPUI for validating and testing

Let me write down the steps in numerical order

1)Create a dotnet application (windows form or console app) and add web reference to your web service
2)Add a WSE client policy config file and attach a authentication token to you proxy
Private Sub DoSettingsForWSE3(ByRef serviceProxy As MyWebService)

Dim strUserName As String = "uname"
Dim strPassword As String = "pwd"
Try
'init web service proxy
serviceProxy = New MyWebService

' Init UsernameToken, password is the reverted
' String of username, the same logic in AuthenticateToken
' of ServiceUsernameTokenManager class.
Dim token As New UsernameToken(strUserName, strPassword, PasswordOption.SendPlainText) 'or encrypted/hased

' Set the token onto the proxy
serviceProxy.SetClientCredential(token)

' Set the ClientPolicy onto the proxy
serviceProxy.SetPolicy("client polciy config")

Catch ex As Exception
Throw
End Try

End Sub

3) Run the test client app and copy the Request constructed from FIDDLER tool

4) Look for the authentication header section from the request constructed by Fiddler.

5) Copy them and test it in SOAPUI tool. 90% you will not go wrong in the authentication part if you do this way.

6) we need to tweak the request in some ways so that it does not expire. Alter the expiration date on the authentication header to some very high future date.

Actually I was struggling to achieve this portion of creating a valid request and then I figured out the way now and would like to share.