0

I have some trouble in trying to consume a function from this webservice https://84.199.99.213:8443/XWS/services

For example and I insert this header into the envelope, I have access to all the functions. But in my C# code, whatever method I tried I got the Unauthorized Error or this exception saying headers are not understood.

<SOAP-ENV:Header>
<Security xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<UsernameToken xmlns:wsse='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd' >
  <Username>###</Username>
     <Password Type='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText'>###</Password>
      </UsernameToken>
</Security>
</SOAP-ENV:Header>  

Here is the authentication sequence and trying to consume a function in my C# project:

        // Create the binding.
        WSHttpBinding myBinding = new WSHttpBinding();
        myBinding.Security.Mode = SecurityMode.Transport;
        myBinding.Security.Transport.ClientCredentialType =
            HttpClientCredentialType.Basic;

        // Create the endpoint address.
        EndpointAddress ea = new EndpointAddress("https://84.199.99.213:8443/XWS/services/cardservice");

        // Create the client. 
        ServiceReference1.CardServiceClient cc =
            new ServiceReference1.CardServiceClient(myBinding, ea);

        // User name and password. 
        cc.ClientCredentials.UserName.UserName = "###";
        cc.ClientCredentials.UserName.Password = "###";

        // Open the client.
        cc.Open();

        //Consume a function 
        ServiceReference1.lookUpItem[] x = cc.listTariffs(null);
        rtbOutput.Text= x.Length.ToString();

What should I have into app.config in order to make it work? Or is something else that I'm missing?

Is anyone able to help me out, please?

Thanks in advance

Urda
  • 5,460
  • 5
  • 34
  • 47
Vlad
  • 1
  • 2
  • Do you have the documentation for the service? Have you verified the authentication protocol? – Shannon Holsinger Oct 03 '16 at 19:07
  • @Shannon Holsinger Yes, i have it. The authentication chapter is this: The Xparc Web Service currently supports the following authentication methods: • UsernameToken (5) ◦ with password of type PasswordText In order to provide a stateless service a client needs to embed the authentication credentials in each request. (5)OASIS Group https://www.oasis-open.org/committees/download.php/13392/wss-v1.1-spec-pr-UsernameTokenProfile-01.htm#_Toc104276211 – Vlad Oct 05 '16 at 07:31
  • I finally solved the problem thanks to Thorarin solution from this post: http://stackoverflow.com/questions/16028014/how-can-i-pass-a-username-password-in-the-header-to-a-soap-wcf-service – Vlad Oct 05 '16 at 09:21
  • Great job, Vlad! Sorry I was asleep when you posted your comment but I'm glad to see yu solved this problem on your own! Cheers. – Shannon Holsinger Oct 05 '16 at 14:08

0 Answers0