January 23rd, 2014, 03:37 PM
How can I consume a webservice that uses WSSE?
Hey everyone. I've run into a problem that I've been trying to figure out for the last 3 days, and I'm not having any luck at all. I'm hoping someone may be able to help me out on something.
I am trying to write a C# Winform application that can access a third party's webservice that uses WSSE. I'll try to provide as many details as possible.
The header for the request needs to be like the following:
I can use the above header (minus the Nonce) in an app called SoapUI and call a method (listStuff) that will return data. However, whenever I try to do so in code, I'm not getting any results. This is what I have tried:
<soapenv:Envelope xmlns:efil="http://someurl.com/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
1. Added a Service Reference to the webservice (https://url.com/Foo?wsdl).
2. Added a namespace to reference this:
3. On a button click event, I then tried to call a method by create a client, setting the username/password, but I am not getting any results:
using Svc = testProject.ServiceReference1;
I'm not getting any exceptions being thrown, but myStuff is empty (it should contain several hundred "stuff" objects).
Svc.CreateInterfaceClient client = new Svc.CreateInterfaceClient();
client.ClientCredentials.UserName.UserName = "username";
client.ClientCredentials.UserName.Password = "password";
Svc.stuff myStuff = client.listStuff();
I haven't had to work with webservices before, and I'm sure it's something that I'm just doing wrong. I haven't had any luck finding any examples online that I can go by to figure this out.
Thanks in advance!
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.