How to send security headers when calling the web service from clr stored procedure

  • Hi,

    I am able to call the web service from clr stored procedure before.

    Now service provider enabled authentication.

    Now CLR stored procedure is not able to invoke the service.

    I verified the SOAP message and soap headers are not going.

    Is there any good sample that I can see?

    Thanks & Regards,

  • Hi there. How exactly are you calling the WebService and what type of authentication is being used? I have successfully used Basic Auth and HttpWebRequest for this by setting the HttpWebRequest.Credentials property. I am sure it would work for other authentication schemes, although you might have to get more specific with the CredentialCache class.

    Hope this helps.

    Take care,

    Solomon..

    SQL#https://SQLsharp.com/ ( SQLCLR library ofover 340 Functions and Procedures)
    Sql Quantum Lifthttps://SqlQuantumLift.com/ ( company )
    Sql Quantum Leaphttps://SqlQuantumLeap.com/ ( blog )
    Info sitesCollations     •     Module Signing     •     SQLCLR

  • Solomon Rutzky, Thank you so much for the quick reply.

    Here are the 4 methods that I tried. None of the these methods are adding SOAP headers in the SOAP message. I monitored network traffic to see SOAP messages

    // 1.

    myProxy.Credentials = new System.Net.NetworkCredential("myuser","mypwd");

    //2.-----------------

    myProxy.UseDefaultCredentials = false;

    myProxy.Credentials = new System.Net.NetworkCredential("myuser","mypwd");

    //3.-----------------

    System.Net.CredentialCache cache = new System.Net.CredentialCache();

    cache.Add(new Uri(myProxy.Url),

    "Basic",

    new System.Net.NetworkCredential("myuser", "mypwd"));

    myProxy.Credentials = cache;

    //4.---------------This is not working since can't add System.ServiceModel

    var basicHttpBinding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential);

    basicHttpBinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;

    myProxy.ClientCredentials.UserName.UserName = "myuser";

    myProxy.ClientCredentials.UserName.Password = "mypwd";

  • I do not think any authentication will be placed in the SOAP <Header> element. I am not sure about all authentication schemes, but I know that Basic Auth is a HTTP Header and would be part of the HttpWebRequest. I have used HttpWebRequest and I believe you can even send in a custom header for the Basic Auth. But I am not sure how to do this via WebService, if that is what you are using.

    Take care,

    Solomon..

    P.S. you might want to edit your post just above this one and change the real password to "mypwd" like you did for most of the occurrences.

    SQL#https://SQLsharp.com/ ( SQLCLR library ofover 340 Functions and Procedures)
    Sql Quantum Lifthttps://SqlQuantumLift.com/ ( company )
    Sql Quantum Leaphttps://SqlQuantumLeap.com/ ( blog )
    Info sitesCollations     •     Module Signing     •     SQLCLR

  • When calling SOA service from SoapUI, I configured the request properties with UN & PWD. Then call went fine

    When calling SOA service from the application, I added security header(that has UN & PWD) in the web.config file. Then call went fine

    When calling SOA service from the CLR, I tried to pass credentials in the code using System.Net.CredentialCache class. Then call failed due to authentication

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply