OBJECT Codeunit 50000 Cust Delete { OBJECT-PROPERTIES { Date=28/08/09; Time=19:33:42; Modified=Yes; Version List=; } PROPERTIES { TableNo=18; OnRun=BEGIN END; } CODE { VAR Customer@1000000000 : Record 18; PROCEDURE DeleteCust@1000000000(VAR CustCode@1000000000 : Text[30]); BEGIN IF Customer.GET(CustCode) THEN Customer.DELETE; END; BEGIN END. } }We have defined the codeunit in Form 810 and marked Publish field true. The codeunit has been called in ASP.NET with C#.NET. The web service has been properly defined and now we have written the following code:
CustDelete cus = new CustDelete(); service.UseDefaultCredentials = true; string a = "C00150"; cus.DeleteCust(ref a);
The request failed with HTTP status 401: Unauthorized. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Net.WebException: The request failed with HTTP status 401: Unauthorized. Source Error: Line 44: [System.Web.Services.Protocols.SoapDocumentMethodAttribute("urn:microsoft-dynamics-schemas/codeunit/CustDelete:DeleteCust", RequestNamespace="urn:microsoft-dynamics-schemas/codeunit/CustDelete", ResponseElementName="DeleteCust_Result", ResponseNamespace="urn:microsoft-dynamics-schemas/codeunit/CustDelete", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] Line 45: public void DeleteCust(ref string custCode) { Line 46: object[] results = this.Invoke("DeleteCust", new object[] { Line 47: custCode}); Line 48: custCode = ((string)(results[0]));
Answers
you are passing Customer by reference, So once you delete the customer, What are expecting to be returned?
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
we are not passing the proper credentials!!
Navision Technical Consultant
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n