Webservice call with .NET from Nav: strange error

rspruitrspruit Member Posts: 25
I made a dll (C#) to call a webservice. Also a test client (console app) in C#. Works perfectly. Next I set up a new form to test the dll from Navision 4.00SP2. Automation variable referring to the typelib. So far so good. Running the form I get the message :

"De aanroep van functie AddArticle is mislukt. System.Web.Services gaf de volgende melding:
De server heeft een fout in het protocol veroorzaakt. Section=ResponseStatusLine"

Translated: The call to the function AddArticle failed. Web.Services returned the following description:
The server caused an error in the protocol. Section=ResponseStatusLine"

You guess my question: HEEELP! ;-)

Answers

  • rspruitrspruit Member Posts: 25
    edited 2006-08-02
    Here the Exception.ToString() output:

    System.Net.WebException: De server heeft een fout in het protocol veroorzaakt. Section=ResponseStatusLine

    bij System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)

    bij System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)

    bij System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)

    bij LogicsWebService.zdlLogicsWebService.Service.AddArticle(String articleCode, String articleName)

    bij LogicsWebService.LogicsWebService.AddArticle(String artCode, String artName)


    I use authentication: clsService.Credentials = new System.Net.NetworkCredential(m_userID,m_password);

    The authentication works well, cause the first calls from Navision were with a invalid user/pwd and that results in the error "401 - unauthenticated" or something like that.

    [edit] Correction on the authentication. If I mess up the login/pwd, I still get the ResponseStatusLine error. But my C# testapp does work fine with the latest webservice dll.[/edit]
  • rspruitrspruit Member Posts: 25
    Navision code:

    IF ISCLEAR(clsWS) THEN
    CREATE(clsWS);
    clsWS.UserID := uID;//=Text: qqq
    clsWS.Password := pwd;//=Text: yyy
    iResult := clsWS.AddArticle(artCode,artName); // 2x Text: X and Y, result = Integer
    CLEAR(clsWS);


    C# code:

    public int AddArticle(string artCode,string artName)
    {
    this.SetCredentials();

    try
    {
    return clsService.AddArticle(artCode,artName);
    }
    catch(Exception e)
    {
    System.Windows.Forms.MessageBox.Show(e.ToString());

    return -1000;
    }

    }


    C# code part from the Webreference/wsdl.exe:

    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://LogiqsAgro.com/AddArticle", RequestNamespace="http://LogiqsAgro.com/", ResponseNamespace="http://LogiqsAgro.com/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
    public int AddArticle(string articleCode, string articleName) {
    object[] results = this.Invoke("AddArticle", new object[] {
    articleCode,
    articleName});
    return ((int)(results[0]));
    }
  • rspruitrspruit Member Posts: 25
    If you need more info let me know, I'll post it tomorrow. For now thanks for your help!
  • rspruitrspruit Member Posts: 25
    Hey BlackTiger, I applied the [...] stuff from your example and it works! But the thing that raises my eyebrows is that the original code also works!
    Beats me! Thanks 100x anyway!

    One little thing that you might also know: Every time I registered the modified dll I get a new entry in the automation server list in Navision. If I unregister the dll with regasm xxxx.dll /u, the entry is not selectable in Navision, but is still there. I register with regasm xxxx.dll /t. Is it possible to use the same entry over and over?
Sign In or Register to comment.