Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

WebService Authentication

Former Member
0 Likes
299

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

1 REPLY 1
Read only

Former Member
0 Likes
262

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