This message was discovered on microsoft.public.dotnet.framework.aspnet.webservices.
| Tim Johnson |
1) How do you get .NET Web Service Client to send the 'Authorization: Basic' Header?
2) How do you get .NET Web Service Client to send SOAP Headers? I tried to send a SOAP header following MS example but it didn't work. The example was for a WEB Service NOT a Web Service Client. The doc says it should work for both but I didn't see it work (No SOAP headers were sent to Apache - I used Apache's TCP Trace tool).
public class MyHeader : SoapHeader { public string Username; public string Password; }
[System.Web.Services.WebServiceBindingAttribute (Name="StockQuoteServiceSoapBinding", Namespace="http://sqnklab02:7676/axis/services/urn:xmltoday -delayed-quotes")] public class StockQuoteService : System.Web.Services.Protocols.SoapHttpClientProtocol { public MyHeader myHeader1;
[System.Diagnostics.DebuggerStepThroughAttribute()] public StockQuoteService() {
myHeader1 = new MyHeader(); this.Url = "http://sqnklab02:7676/axis/services/urn:xmltoday- delayed-quotes"; }
[System.Diagnostics.DebuggerStepThroughAttribute()] [System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace="urn:xmltoday-delayed-quotes", ResponseNamespace="urn:xmltoday-delayed-quotes")]
[SoapHeader("myHeader1", Direction=SoapHeaderDirection.Out)] public System.Single getQuote(string arg0) { myHeader1.Username = "user1"; myHeader1.Password = "pass1";
object[] results = this.Invoke("getQuote", new object[] {arg0}); return ((System.Single)(results[0])); }
|
|
| |
| |
| Pierre |
[Original message clipped]
Look on NetworkCredential class and set it on your proxy client.
[Original message clipped]
Did you look at http://www.c-sharpcorner.com/SOAP/WSBNJNCT2.asp ?
Pierre
|
|
| |
| |
| Tim Johnson |
Pierre, I need help. I tried the following , but nothing went back to Apache.
[System.Web.Services.WebServiceBindingAttribute (Name="StockQuoteServiceSoapBinding", Namespace="http://sqnklab02:7676/axis/services/urn:xmltoday -delayed-quotes")] public class StockQuoteService : System.Web.Services.Protocols.SoapHttpClientProtocol { [System.Diagnostics.DebuggerStepThroughAttribute()] public StockQuoteService() { NetworkCredential nc = new NetworkCredential ("user1", "pass1"); this.Credentials = nc; this.Url = "http://sqnklab02:7676/axis/services/urn:xmltoday- delayed-quotes"; }
[Original message clipped]
|
|
| |
| |
| Pierre |
Sorry, I forgot the second part of the question. So, you have tho make something like follows:
this.GetWebRequest(new Uri("http://localhost/WSTest/SimpleService.asmx")).Headers.Add("TestHeader", "TestValue");
Pierre
[Original message clipped]
|
|
| |
| |
| Tim Johnson |
I could not get the Authorization Header or the Custom Headers or the SOAP Headers to work. I give up - I tried everthing I could think of.
Pierre, thanks for your responses, but I couldn't get your code examples to work on my box - Windows 2000 Professional (work station - NOT a server). (I don't know if that makes a difference or not??)
[Original message clipped]
("TestHeader", [Original message clipped]
|
|
| |
|
|
| |
| Pierre |
Tim, I don't have Apache here but I setted my IIS to "Basic Authentication" (only that one) that is exaclty what you have (clear text password). On the constructor of my web service proxy I added the network credentials as you done:
NetworkCredential myCred = new NetworkCredential("myuserid","password",""); this.Credentials = myCred;
It works fine for me.
Pierre
"Tim Johnson" <Click here to reveal e-mail address> wrote in message news:28da01c15d6b$a9a34d20$35ef2ecf@TKMSFTNGXA11... [Original message clipped]
|
|
| |
|
|
|
|
|
|
|