cancel
Showing results for 
Search instead for 
Did you mean: 

Web Service call

Former Member
0 Kudos

Dear all,

Hello,

I created a web service in SAP using the SAOMANAGER. I successfully added the web service into my visual studio 2008 project and able to see the web service methods. However when I call the web service method on run time it throws unauthorized error 401. I am the admin on the system.

Any help will be appreciated on this.

Thanks,

Ameha

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

SAP service call needs proper authentication. so you need to configure user/password for calling service from .Net studio.

search SDN for sample code (same user/password which you used to fetch wsdl).

Regards,

Gourav

Former Member
0 Kudos

Thanks for the prompt response,

Below is the code I used to call SAP service, it works perfectly for SAP Net weaver 7.0 SR3 IDES, But currently we upgrade our system to SAP Net Weaver 7.0 EHP4 IDES and I am getting unauthorized error at the code (Serviceobj.CompanycodeGetlist(ob1) despite I am the u201CGodu201D on the system the same as the previous system. Am I missing something here?

<host>.service Serviceobj = new <host>.service();

<host>.Bapi00021[] arry = new <host>.Bapi00021[20];

<host>.CompanycodeGetlist ob1 = new <host>.CompanycodeGetlist();

Serviceobj.PreAuthenticate = true;

NetworkCredential objCred = new NetworkCredential("Myusername", "Mypassword");

CredentialCache creCatch = new CredentialCache();

creCatch.Add(new Uri("http://WSDL url"), "Basic", objCred);

Serviceobj.Credentials = creCatch;

Serviceobj.CompanycodeGetlist(ob1)

for (int i = 0; i < arry.Length; i++)

{

Console.WriteLine(arry<i>.CompCode.ToString());

}

Console.WriteLine();

Console.ReadLine();

Former Member
0 Kudos

Check that the service in transaction SICF that corresponds to your Web Service is active. You can get the SICF path from the URL of your Web Service.

Former Member
0 Kudos

Hi,

Possibly wsdl url is changed. You should reconfigure service in SOAMANAGER and then reimport the wsdl in .Net application.

Regards,

Gourav