Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

How to send security headers when calling the web service from clr stored procedure Expand / Collapse
Author
Message
Posted Friday, April 4, 2014 10:25 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, April 29, 2014 10:05 AM
Points: 34, Visits: 90
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,
Post #1558589
Posted Friday, April 4, 2014 11:12 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: 2 days ago @ 3:00 PM
Points: 368, Visits: 1,957
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# - http://www.SQLsharp.com/
Post #1558599
Posted Friday, April 4, 2014 11:26 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, April 29, 2014 10:05 AM
Points: 34, Visits: 90
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";
Post #1558600
Posted Monday, April 7, 2014 11:32 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: 2 days ago @ 3:00 PM
Points: 368, Visits: 1,957
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# - http://www.SQLsharp.com/
Post #1559204
Posted Tuesday, April 8, 2014 9:34 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, April 29, 2014 10:05 AM
Points: 34, Visits: 90
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
Post #1559544
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse