‎2009 Oct 19 7:23 PM
Hello All,
I have created a WebService on SAP ECC 6, and would like to use it on my .NET program. (C# CSHARP language).
But, How can I inform the user and password? How can I authenticate on SAP ECC?
A piece of code:
WebReference.zwservice zwservice = new WebReference.zwservice();
WebReference.zwsmethodo zwsmethodo = new WebReference.zwsmethodo();
zwsmethodo.I_ENTRADA = "1";
WebReference.zwsmethodoResponse zresp = zwservice.zwsmethodo(zwsmethodo);
Console.WriteLine("Resp ", zresp.E_NOME);
Thanks!
Marcel
‎2009 Oct 28 5:56 PM
Hello All,
I found the solution.
In Visual C# 2008 Express Edition, was necessary to override the method System.Net.WebRequest GetWebRequest, and inform the username and password.
Jut insert this code in the partial class!
protected override System.Net.WebRequest GetWebRequest(Uri uri)
{
System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)base.GetWebRequest(uri);
request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(new System.Text.ASCIIEncoding().GetBytes("USERNAME" + ":" + "PASSWORD")));
return request;
}
Regards,
Marcel