SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


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


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

Author
Message
gsd1
gsd1
SSC Veteran
SSC Veteran (286 reputation)SSC Veteran (286 reputation)SSC Veteran (286 reputation)SSC Veteran (286 reputation)SSC Veteran (286 reputation)SSC Veteran (286 reputation)SSC Veteran (286 reputation)SSC Veteran (286 reputation)

Group: General Forum Members
Points: 286 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,
Solomon Rutzky
Solomon Rutzky
Hall of Fame
Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)

Group: General Forum Members
Points: 3368 Visits: 3029
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/
gsd1
gsd1
SSC Veteran
SSC Veteran (286 reputation)SSC Veteran (286 reputation)SSC Veteran (286 reputation)SSC Veteran (286 reputation)SSC Veteran (286 reputation)SSC Veteran (286 reputation)SSC Veteran (286 reputation)SSC Veteran (286 reputation)

Group: General Forum Members
Points: 286 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";
Solomon Rutzky
Solomon Rutzky
Hall of Fame
Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)

Group: General Forum Members
Points: 3368 Visits: 3029
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/
gsd1
gsd1
SSC Veteran
SSC Veteran (286 reputation)SSC Veteran (286 reputation)SSC Veteran (286 reputation)SSC Veteran (286 reputation)SSC Veteran (286 reputation)SSC Veteran (286 reputation)SSC Veteran (286 reputation)SSC Veteran (286 reputation)

Group: General Forum Members
Points: 286 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
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search