CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Jan 2014
    Posts
    7

    Question 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:

    Code:
    <soapenv:Envelope xmlns:efil="http://someurl.com/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
       <soapenv:Header>
          <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">
             <wsse:UsernameToken wsu:Id="UsernameToken-3">
                <wsse:Username>myusername</wsse:Username>
                <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">mypassword</wsse:Password>
                <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">Uw0swuaymypUcDTUpJ0i0Q==</wsse:Nonce>
                <wsu:Created>2014-01-22T15:48:32.809Z</wsu:Created>
             </wsse:UsernameToken>
          </wsse:Security>
       </soapenv:Header>
       <soapenv:Body>
          <efil:listStuff/>
       </soapenv:Body>
    </soapenv:Envelope>
    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:

    1. Added a Service Reference to the webservice (https://url.com/Foo?wsdl).
    2. Added a namespace to reference this:
    Code:
    using Svc = testProject.ServiceReference1;
    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:
    Code:
    Svc.CreateInterfaceClient client = new Svc.CreateInterfaceClient();
    client.ClientCredentials.UserName.UserName = "username";
    client.ClientCredentials.UserName.Password = "password";
    
    client.Open();
     
    Svc.stuff[] myStuff = client.listStuff();
    
    client.Close();
    I'm not getting any exceptions being thrown, but myStuff is empty (it should contain several hundred "stuff" objects).

    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!

  2. #2
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: How can I consume a webservice that uses WSSE?

    If there is no API, then you might be out of luck. If it's your service, you know how to call it.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Jan 2014
    Posts
    7

    Re: How can I consume a webservice that uses WSSE?

    Unfortunately, the only thing the third party gave me was a document with a list of methods - but not examples at all of how to call any of their methods. They are a Java shop, so they can't provide me with any working example or code snippets. So, I'm stuck trying to figure this stuff out.

    I'm at a loss on how to get this figured out.

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: How can I consume a webservice that uses WSSE?

    Take a look at Microsoft Azure. You can sign up for a free account, and deploy services.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    Jan 2014
    Posts
    7

    Re: How can I consume a webservice that uses WSSE?

    Quote Originally Posted by dglienna View Post
    Take a look at Microsoft Azure. You can sign up for a free account, and deploy services.
    Thanks, but I don't think that'll help me in writing a client to connect to that third party's webservice.

  6. #6
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: How can I consume a webservice that uses WSSE?

    Why, the concept is the same. Take a look here: http://msdn.microsoft.com/en-us/library/bb165052.aspx
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  7. #7
    Join Date
    Jan 2014
    Posts
    7

    Re: How can I consume a webservice that uses WSSE?

    I'm thinking the problem is related to the formatting of the headers for WSSE. Not real sure how to tackle that.

  8. #8
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: How can I consume a webservice that uses WSSE?

    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  9. #9
    Join Date
    Jan 2014
    Posts
    7

    Re: How can I consume a webservice that uses WSSE?

    Thanks for your help. I was finally able to get it connecting. I had to write out some classes to handle custom headers. Hmmm..that link you attached seems to be a bit more elegant way of doing it than what I ended up doing. Thanks again man!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured