Webservice using xmlport error- parameter in method is null

skullaskulla Member Posts: 140
edited 2012-09-18 in NAV Three Tier
Hello Everyone,

I am building a simple .net application using VS 2012. I have published a codeunit in Navision which has one single function with xmlport as parameter. I have added Navision web service using service reference and I am using asynchronous methods of the web service to call the function but when ever I call my method I am getting Parameter xxxxx in method xxxxx in service xxxxxx is null. If I change my codeunit function parameter to normal instead of passing it by reference I do not get that error but also I don't get any data back from Navision. I do not want to use synchronous methods. Any help or suggestions are appreciated.

p.s. If I use VS 2010 with synchronous methods then call is working fine.

Comments

  • kinekine Member Posts: 12,562
    You need to set the parameter to something different than null when calling the function. And check the min occurance on the nodes of the xmlport, because if there is Once, there cannot be null....
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • skullaskulla Member Posts: 140
    Kamil thank you for your reply. I am passing parameter to the function call.

    ExportCurrency expcurrency = new ExportCurrency();
    ExportCurrency_Result ExpCurrResult = await Services.ExportCurrencyAsync(expcurrency);

    I have also checked the nodes MinOccurs property they all set to once.
  • kinekine Member Posts: 12,562
    I have also checked the nodes MinOccurs property they all set to once.

    If there is Once, you need to create all objects inside the object to not have any null inside. If you want to have possibility to pass null, you need to set the min occurance to Zero and make the value optional in this way.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • skullaskulla Member Posts: 140
    I currently have only two fields from currency table which is code and description, so they have values. I am thinking the error is happening because of pass by reference.
  • Allan_BollAllan_Boll Member, Microsoft Employee Posts: 7
    I recommend testing the exposed webservice with a tool such as SoapUI or Storm and see whether everything works as expected. This can help you narrow down whether the issue is in your C# code or your NAV app. Though this sounds mostly like it's in the C# code...

    If you're sure that "expcurrency" is set to pass by reference in NAV, then to me it looks like something went wrong when the service reference was added in VS. I would expect that the C# proxy required the "ref" keyword on the parameter. However, I haven't used the new async/await keywords in C# myself yet, so I may be mistaking.

    You mentioned that the synchronous generated version of the method works. A workaround may be to start a thread with the service call, and do a thread.join or something similar in the place where you need the result.
  • Sayan81Sayan81 Member Posts: 10
    I got the same error some days back and that happened because of case mismatch in the parameter name. For eg, in the function in codeunit , the parameter is defined as filepath where as when I am calling that function through SOAP , I have written as <Filepath>.
    Once I changed that to <filepath> it worked.
  • skullaskulla Member Posts: 140
    Thank you for the replies, my webservice connection is working and i tested this using SOAPUI. The parameter names does match. I am still getting same error i strongly believe that NAV WS is not supporing call by reference asynchronously, i ended up creating a function in codeunit and in that function i exported XMLport and returned back the text string with XML. I exposed that codeunit as webservice and everything works as expected.
Sign In or Register to comment.