Navision HTTP Server

jabusjabus Member Posts: 2
Hi,

for integrating another system with Navision, I have to receive a request via HTTP (XML) in Navision and sent the response back in the same way.
Communication is always triggered by the partner system - not from Navision.
I have already experimented with the 'Microsoft XML, v5.0'.XMLHTTP automation control in Navision.
But how can I implement the Navision Server functionality waiting on a specific port for HTTP requests?
For the moment my only solution would be on TCP/IP Socket level...

Does anybody have a suggestion?

Thanks in advance,
Jan

Comments

  • pduckpduck Member Posts: 147
    I searched for such a solution some times ago.

    You cannot implement this with only using Navision and the MS Components. So I thougt about an own Automation Object working as HTTP Server which triggers an Event in MS and passes the Document as a Stream to Navision.
    The Problem was the incompatible Stream-Technology in Navision. The Navision Streams differ from e.g. Borland Delphi Streams. So it seems that you must implement a small HTTP Server which communicates with Navision throught its TCPSocket Component (or Pipe and Message Queue).

    Another idea was using the TCPSockets Components and implement the whole HTTP Communication Protocol together with the Application Server.
    As far as i know Navision is not multithreaded so the implementation of HTTP Server functionality in the Application Server could be quite difficult.

    Up to now I am not glad with these solutions and didn't start to implement one of them ;) Any other good ideas or experiences?
  • ara3nara3n Member Posts: 9,256
    Wait for navision 5 :mrgreen:
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • This topic's a bit old, but anyway.. someone may find it useful.

    I don't kow about Navision 5+ but in 4.0 you could do the HTTP web service like this:
    - make a NAS agent listening on a socket using standard Navision Communications Components.
    - set up Apache HTTP server (it's really easy), install mod_python and do some python magick to wrap your NAS agent with a true HTTP server.

    For example, if you want your Navision web service to respond to a method POST http requests, set up a mod_python publisher handler and create a script in apache htdocs directory like this:

    default.py
    import socket
    
    def execute(req, xml):
    
        nas_host = 'nasagent'
        nas_port = 8081
    
        request = xml
    
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.connect((nas_host, nas_port))
        s.sendall(request)
        s.shutdown(socket.SHUT_WR)
        
        response = ''
        while True:
            r = s.recv(4096)
            if not r: break
            response += r
    
        req.content_type = 'text/xml'
        return response
    


    now, when you POST data to

    http://apachehost/default.py/execute

    You should specify xml parameter and the script (default.py) will send the data to your NAS agent (nasagent:8081), which in turn should respond with something that the HTTP server will sent back as an text/xml content type.
Sign In or Register to comment.