Question

I was hoping you could help me out. I am trying to connect to a 3rd party webservice which unfortunately is a WSE 2.0 service. I am trying to write the client in C# .NET 4.0 using WCF. I am having no luck at all finding any info on this. The service requires a string for the username and password. Here is what their sample looks like

Using webServiceObject As Microsoft.Web.Services2.WebServicesClientProtocol = New WSOData.Webservices.TransactionWebService()
https = ConcatenateWebserviceAddress(request.Server.Https, request.Service.Extension)
epr = New EndpointReference(New Uri(https))
webServiceObject.Destination = epr

Dim WebserviceContext As SoapContext = webServiceObject.RequestSoapContext

''''' Set the security settings
 ' Set the timeout value for how long issued SecurityContextToken security tokens are valid
WebserviceContext.Security.Timestamp.TtlInSeconds = -1

'Instantiate a new UsernameToken object.
Dim userNameToken As New UsernameToken(userName, password, PasswordOption.SendHashed)

'Add the token to the SoapContext.
WebserviceContext.Security.Tokens.Add(userNameToken)

'Generate a signature using the username token, and add the signature to the SoapContext.
 WebserviceContext.Security.Elements.Clear()
 WebserviceContext.Security.Elements.Add(New MessageSignature(userNameToken))

Is there any way to accomplish this using WCF in .NET 4.0? I don't really want to have to resort to using WSE 2.0 if I can help it. I also have no control over the service we are connecting to. Any help would be appreciated, I am by no means a WCF expert or novice for that matter.

Thanks in advance

Was it helpful?

Solution

In theory, you can probably create the right extensions and behaviors to get WCF to produce & consume WSE 2.0 soap but you're on your own here. There is some interop between WSE 3.0 and WCF as documented in this blog post. You could use it as a starting point to try working with the WSE 2.0 service.

You may be better off working directly with the original WSE 2.0 components if you can find a copy of Visual Studio 2003. I vaguely remember that WSE 2.0 has 3 service packs that weren't backward compatible so you should insure you match the correct service pack. Good luck & the best of wishes!! :)

OTHER TIPS

I do not recommend for you to use WSE2. In the worse case - where Wcf is not able to interoperate with this service - you would be better off to create the username header yourself, it is not too hard. But to determine the best way please publish a full working soap sample (the vendor should supply one)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top