Options

Issue in delete function customer table webservices

Ashish_GuptaAshish_Gupta Member Posts: 56
edited 2009-08-28 in NAV Three Tier
We have prepared the following code unit in NAV
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);

We are receiving the following error :
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]));
Ashish Gupta
Navision Technical Consultant

Answers

  • Options
    ara3nara3n Member Posts: 9,255
    I'm assuming insert customer or modifying works?

    you are passing Customer by reference, So once you delete the customer, What are expecting to be returned?
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    Ashish_GuptaAshish_Gupta Member Posts: 56
    it was our fault!!

    we are not passing the proper credentials!!
    Ashish Gupta
    Navision Technical Consultant
  • Options
    ara3nara3n Member Posts: 9,255
    That's what I thought as well, but wanted to make sure it wasn't just deleting customers.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
Sign In or Register to comment.