on 08-31-2008 10:15 PM
I am trying to call a webservice on the ESOA located at sdn.sap.com and am getting an authorization error.
(Note: I am sure teh USERID and PASSWORD is valid).
Here is my Code
//Instantiate the web service
sap.CustomerERPSimpleByIDQueryResponse_InService sapService = new sap.CustomerERPSimpleByIDQueryResponse_InService();
//Define Login ICredentials cred = new NetworkCredential ("USERID", "PASSWORD");
sapService.Credentials = cred;
//Instantiate the parameters pass the the method
sap.CustERPSimplByIDQry_sSel selection = new sap.CustERPSimplByIDQry_sSel();
sap.CustERPSimplByIDQry_sProcgCond proccondin = new sap.CustERPSimplByIDQry_sProcgCond();
sap.CustERPSimplByIDRsp_sProcgCond proccondout = new sap.CustERPSimplByIDRsp_sProcgCond();
sap.NOSC_Log log = new sap.NOSC_Log();
//Select Customer with ID = "1"
selection.ID = "1";
//Call the web method
sapService.CustomerERPSimpleByIDQueryResponse_In(selection, proccondin, out proccondout, out log);
However when I tryo to call the web method, I get this exception:
System.Net.WebException was unhandled
Message="The request failed with HTTP status 401: Unauthorized."
Source="System.Web.Services"
StackTrace:
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at WindowsFormsApplication1.sap.CustomerERPSimpleByIDQueryResponse_InService.CustomerERPSimpleByIDQueryResponse_In(CustERPSimplByIDQry_sSel CustomerERPSimpleSelectionByID, CustERPSimplByIDQry_sProcgCond ProcessingConditions, CustERPSimplByIDRsp_sProcgCond& ProcessingConditions1, NOSC_Log& Log)
at WindowsFormsApplication1.Form1.button1_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at WindowsFormsApplication1.Program.Main()
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
Hi,
for SAP service:
NetworkCredentials cred = new NetworkCredentials("SAPUSER", "SAPPASSWORD");
service.credentials = cred;
for IIS service:
service.Credentials = CredentialCache.DefaultCredentials;
regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.