Hi,
I have to use a Java web service that requires HTTP authentication, so
I have to send username and password in the HTTP headers.
My C# application has a client implementation that looks like this:
[System.Diagnost ics.DebuggerSte pThroughAttribu te()]
[System.Componen tModel.Designer CategoryAttribu te("code")]
[System.Web.Serv ices.WebService BindingAttribut e(Name="MyServi ceSoapBinding",
Namespace="http ://localhost:8080/services/MyService")]
public class MyService :
System.Web.Serv ices.Protocols. SoapHttpClientP rotocol {
public MyService() {
this.Url = "http://localhost:8080/services/MyService";
}
[System.Web.Serv ices.Protocols. SoapRpcMethodAt tribute("",
RequestNamespac e="http://webservices.my" ,
ResponseNamespa ce="http://localhost:8080/services/MyService")]
public void addUserData(Use rData in0) {
this.Invoke("ad dUserData", new object[] {
in0});
}
public System.IAsyncRe sult BeginaddUserDat a(UserData in0,
System.AsyncCal lback callback, object asyncState) {
return this.BeginInvok e("addUserData" , new object[] {
in0}, callback, asyncState);
}
public void EndaddUserData( System.IAsyncRe sult asyncResult) {
this.EndInvoke( asyncResult);
}
};
The client uses the service like this:
MyService myService = new MyService();
myService.addUs erData(userData );
It works fine, if no authentication is required. How can I implement
the HTTP authentication?
Thanks,
Markus Brandy
I have to use a Java web service that requires HTTP authentication, so
I have to send username and password in the HTTP headers.
My C# application has a client implementation that looks like this:
[System.Diagnost ics.DebuggerSte pThroughAttribu te()]
[System.Componen tModel.Designer CategoryAttribu te("code")]
[System.Web.Serv ices.WebService BindingAttribut e(Name="MyServi ceSoapBinding",
Namespace="http ://localhost:8080/services/MyService")]
public class MyService :
System.Web.Serv ices.Protocols. SoapHttpClientP rotocol {
public MyService() {
this.Url = "http://localhost:8080/services/MyService";
}
[System.Web.Serv ices.Protocols. SoapRpcMethodAt tribute("",
RequestNamespac e="http://webservices.my" ,
ResponseNamespa ce="http://localhost:8080/services/MyService")]
public void addUserData(Use rData in0) {
this.Invoke("ad dUserData", new object[] {
in0});
}
public System.IAsyncRe sult BeginaddUserDat a(UserData in0,
System.AsyncCal lback callback, object asyncState) {
return this.BeginInvok e("addUserData" , new object[] {
in0}, callback, asyncState);
}
public void EndaddUserData( System.IAsyncRe sult asyncResult) {
this.EndInvoke( asyncResult);
}
};
The client uses the service like this:
MyService myService = new MyService();
myService.addUs erData(userData );
It works fine, if no authentication is required. How can I implement
the HTTP authentication?
Thanks,
Markus Brandy
Comment