none
wsHTTPBinding and accessing a JBoss Server with preemptive Authorization RRS feed

  • Question

  • Hello,

    I am trying to access a Jboss SOAP Webservice with Transport Security. From SoapUI I can do ist successfully. In my C# windows form I always receive a 401 error, unauthorized.

    Analysing the data at SoapUI and comparing them with the data traced by fiddler I can find a major difference in the Request Header: The SoapUI contains Authorization: Basic c29hcFVzZXI6WUhdaz1DQg== which corresponds to the switch "Preemptive Authorization" at SoapUI.

    So far I have tried a lot of different settings at the transport layer, but I was unable to get this field into the request header.

    Does anybody know if I can get this preeemtive Authentication field into the wsHTTPbinding request?

    thanks!

    sethach

    Friday, August 16, 2013 4:30 PM

All replies

  • Hi,

    Please try to refer to the following to add the following field into the request header:

    var client = new WCClient();  
    
            using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
                 {
                     var httpRequestProperty = new HttpRequestMessageProperty();
                     httpRequestProperty.Headers[System.Net.HttpRequestHeader.Authorization] = "Basic " +
                     Convert.ToBase64String(Encoding.ASCII.GetBytes(client.ClientCredentials.UserName.UserName + ":" +
                     client.ClientCredentials.UserName.Password));
                     OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] =
                        httpRequestProperty;
    
                       client.DoSomething();
                }

    For more information, please try to refer to the following links:

    http://blogs.msdn.com/drnick/archive/2008/07/08/adding-headers-to-a-call-http-version.aspx .

    http://plainoldstan.blogspot.com/2008/07/avoid-http-401-roundtrip-with-adding.html .

    Best Regards,
    Amy Peng


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.




    Wednesday, August 21, 2013 5:21 AM
    Moderator
  • Hello Amy,

    thank you for your reply. In the meantime they could change the server so that the preemptive Authentication is now optional. However, I could mange to access the server.

    Unfortunately I now have the next problem, which I have posted in another thread.

    Thank you

    Friday, August 23, 2013 2:59 PM