Calling webservice from nav2013

Benno67Benno67 Member Posts: 39
edited 2012-09-28 in NAV Three Tier
Hi All,

We have a problem in NAV2013 that we donot understand:
We are trying to compile a CU with a XmlHTTPConn creation in it. Compiling goes well, from the designer, but saving gives an error message : You cannot create an Automation object "XmlHttpConn" on Microsoft Dynamics NAV Server. You must create it on a client computer.
The solution apperently is : place the creation between a "if not isservicetier" begin/end. Afterwards we are able to save and compile the codeunit.
The only problem that remains is executing the codeunit : In NAV2013 the coding is always running on the servicetier? So calling webservices is not possible anymore?

How do we create objects on a client in NAV2013?

Regards
Benno

Answers

  • kinekine Member Posts: 12,562
    You need to use .NET interop. Try to use .net assemblies to do what you need instead Automations...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Benno67Benno67 Member Posts: 39
    I am not amused, found out that it is possible to create automations client site, but ran into the fact that streming is not supported anymore, at least client site streaming :thumbsdown:
    By having to use Interopt we are back at the discussions last TechDay's on using .Net by Navision developers.....

    Thanks Anyway, not you fault :D
  • kinekine Member Posts: 12,562
    I hardly remember the discussion, but yes, we need to learn .net, but .net interop with events is better way than automations...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • krikikriki Member, Moderator Posts: 9,112
    [Topic moved from 'NAV/Navision Classic Client' forum to 'NAV Three Tier' forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Benno67Benno67 Member Posts: 39
    Hi Kine,

    Maybe I am a bit stubborn on not wanting to use .NET Interopt. It has to do with being afraid to lose the “old” skills and productivity, and getting back more time consuming .NET programming.

    Perhaps you can help to solve this problem with Interopt, and prove me being to skeptical :

    I want to read a XmlFile into a XmlDoc. In the classic environment it can be solved easy with In/OutStreams
    Running it on NAV2013 results in : Streams cannot be used with client-side invoked automation objects.

    Can you give me a start on how to solve it with Interopt (Simply declaring a DONET Memory Stream variable is not the answer)

    Benno
  • kinekine Member Posts: 12,562
    And the XML is saved on disk? You can use the load member of the XMLDocument class to load it, no?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Benno67Benno67 Member Posts: 39
    The XmlDoc has to be created client site, (server site is not possible since the cu is running client site).
    Trying to load the XmlFile (on the server) results in an empty XmlDoc.
    Copying the save XmlDoc to the client, and loading it from there makes it all working.
    Creating the XmlFile on the client does not work either, because it has to be filled using a XmlPort, with streams... and they do not work on the client.

    Trying to do something Microsoft did not thought of?
  • kinekine Member Posts: 12,562
    Why the CU is run on client? Can you run it rather on server?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • thegunzothegunzo Member Posts: 274
    With the help of Codeunit 419 and Table 99008535 you should be able to stream your XMLPort to tempBLOB and stream it to a client side temporary file that you can open with them XMLDoc automation on the client. Right ?

    1. Create an outstream based on tempBLOB
    2. Export using XMLPort
    3. Create an instream based on the same tempBLOB
    4. DOWNLOADFROMSTREAM into a client side file
    5. Use XMLDoc.load to import the file.
    ________________________________
    Gunnar Gestsson
    Microsoft Certified IT Professional
    Dynamics NAV MVP
    http://www.dynamics.is
    http://Objects4NAV.com
  • Benno67Benno67 Member Posts: 39
    Life can be very simple!

    Did not know of the existence of DOWNLOADFROMSTREAM!

    Thanks Gunner and Kine :thumbsup:
  • PConijnPConijn Member Posts: 31
    We will need to go over to .NET eventually, but if you are adamant on creating an automation on the 3-tier structure, then you need to use the optional parameters or NewServer and OnClient. The full function description is: [Ok :=] CREATE(Automation [,NewServer] [,OnClient])

    This means that CREATE(XmlHttpConn, FALSE, TRUE) will prevent this error from occurring.
    Kind Regards,

    Peter Conijn

    -The Learning Network-

  • thegunzothegunzo Member Posts: 274
    I created a web request dotnet code for nav 2009 that should work for nav 2013.

    http://www.dynamics.is/?p=1018
    ________________________________
    Gunnar Gestsson
    Microsoft Certified IT Professional
    Dynamics NAV MVP
    http://www.dynamics.is
    http://Objects4NAV.com
  • Benno67Benno67 Member Posts: 39
    Hi Gunnar,

    Exactly my question, without automation, no server/client site dependency's!
    I am going to fit it in into our old solution, and try it on Nav2013.

    Thanks
    Benno
  • Lars_WestmanLars_Westman Member Posts: 116
    I've just started looking into this in NAV2013 and got a bit confused.

    I can create my XMLHttpConn using CREATE(XMLDoc, FALSE, TRUE), call Send and load the response into an XMLDoc. I can pass that XMLDoc as a variable to a a function in a codeunit which saves a debug xml file on my file system and the files looks just fine. But I cant pass the XMLDoc to a function in a codeunit where I try to use the XMLDoc whith functions like XMLDoc.getElementsByTagName to process it.

    Any suggestions?
  • Lars_WestmanLars_Westman Member Posts: 116
    It was XML6.0 that caused my problems. changing to XML3.0 fixed it
Sign In or Register to comment.