web service - Load Request and retrieve large xml message

zyrosevenzyroseven Member Posts: 20
edited 2012-05-14 in NAV Three Tier
Hi, i have a requirement to build a web service that should load a request from an xml message and retrieve very large xml message that will be build according to the request, and will have about 20 possible structures. For the request i am thinking of using 'Microsoft XML, v3.0'.DOMDocument Automation, but i have no idea how to make the response. Anyone with experience in this scenario? Any information will be great because i have no experience with web services.

many thanks

Comments

  • nXqdnXqd Member Posts: 39
    ok, i'm beginner too but I'm working with webservice at the moment. You can use XMLHTTP to get this job done.
    For more information, take a look at this great example :
    http://www.mibuso.com/dlinfo.asp?FileID=539


    hope this helps
  • zyrosevenzyroseven Member Posts: 20
    thanks nXqd, i will take a look in your suggestion
  • Dan77Dan77 Member Posts: 17
    Hi,

    would this topic exposing webservices through codeunit and xmlports be useful, maybe?

    http://blogs.msdn.com/b/freddyk/archive ... stuff.aspx
  • zyrosevenzyroseven Member Posts: 20
    Hi Dan77, thank you for your reply. This could be a solution but my problem is that i have to retrieve different kinds of xml files, so xmlport is not really an option unless i could retrieve plain text maybe? Will investigate this option :o
  • Dan77Dan77 Member Posts: 17
    I have not been involved into some recent devs we made to exchange with some portal here, but our guys met pretty much all the known needs with this technique.

    I would be glad to send you more of that stuff, if it can help, but I can't on my own

    Good luck
  • kinekine Member Posts: 12,562
    If you do not know the structure before import, you can use BigText parameter in the WS function. Than you can process it as you want, e.g. check which structure was sent and stream it into correct XMLPort throuh code.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • zyrosevenzyroseven Member Posts: 20
    Hi Kine, the problem is to handle the response, because it can have different structures :?

    Thanks
  • kinekine Member Posts: 12,562
    Again, you can send the data back through BigText parameter which is VAR (Passed by refference). Than you can only stream the correct XMLPort into this bigtext variable and you are done...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • zyrosevenzyroseven Member Posts: 20
    Thanks kine, sorry i didn't understood at first but i am a bit confused since this is a new subject for me :oops:
    Your help has been great (an example would be even better [-o< )

    Thanks
  • kinekine Member Posts: 12,562
    See e.g. this: http://blogs.msdn.com/b/freddyk/archive ... vices.aspx
    it is for image, but you can modify it to not send binary data encoded into base64, but just send/receive any XML you want...

    Or this: http://blogs.msdn.com/b/freddyk/archive ... -of-3.aspx
    BigText parameter is used to return the result.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • zyrosevenzyroseven Member Posts: 20
    Brilliant Kine, just what i needed! \:D/
  • zyrosevenzyroseven Member Posts: 20
    Well, something is still confusing me :-k
    How can i use the xml port for response if i dont know the structure it should have? Can it be an empty xmlport? Basically all i want to do is to pick up an 'Microsoft XML, v3.0'.DOMDocument structure and send it to xmlport so it can be returned by the webservice. Because this xml dom structure can be created in about 40 different structures its not reliable to build 40 different xml ports (one for each structure) and test evertything etc, so i must find a solution to "wrap" the xml dom document and return it from the web service.
  • kinekine Member Posts: 12,562
    Of course, you cand create the xml through XML Dom or 40 XML Ports. All depends on the complexity and other things around. That's on you. E.g. for me having 40 XML Port could be much better for support and changes than maintain codeunit creating 40 different structures by code full of conditions and other things. But again, I do not know the requirements.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • thegunzothegunzo Member Posts: 274
    There is also a easy way to use dotnet to base64 encode the file into the bigtext variable.

    For example, if I have the bigtext variable Document the code could be

    TempFile.CREATETEMPFILE;
    TempFileName := TempFile.NAME;
    TempFile.CLOSE;
    TempFile.TEXTMODE(FALSE);
    TempFile.CREATE(TempFileName);
    TempFile.CREATEOUTSTREAM(OutStr);
    DocumentStore.Blob.CREATEINSTREAM(InStr);
    COPYSTREAM(OutStr,InStr);
    TempFile.CLOSE;
    
    Document.ADDTEXT(
      ServerConvert.ToBase64String(
        ServerDocumentFile.ReadAllBytes(TempFileName)));
    
    ServerDocumentFile.Delete(TempFileName);
    

    where the dotnet variables are
    Name DataType Subtype Length
    ServerConvert DotNet 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Convert
    ServerDocumentFile DotNet 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.File
    ________________________________
    Gunnar Gestsson
    Microsoft Certified IT Professional
    Dynamics NAV MVP
    http://www.dynamics.is
    http://Objects4NAV.com
  • zyrosevenzyroseven Member Posts: 20
    Thanks for the responses, the thing is that i already have the codeunit that creates the 40 different xml structures using XML DOM automation and is used in a integration via Message Queues, i just need to change for integration with web services. I just dont understand how can i pass a xml dom to a xmlport, what has to be done in the xmlport because the same xmlport needs to receive 40 different XML DOM files. Because of this i can't define any structure in the xml port, so have no idea how to handle it. :-k
Sign In or Register to comment.