2 Replies Latest reply on Sep 6, 2016 4:50 AM by Vamitul

    Socket - xml back to server

    brianc49423945

      I have a long script running (on InDesign) that I would like to keep track of running on another PC in our network.

       

      I've created a simple Jquery/Boostrap web interface that reads in a XML file every few minutes. So what I am looking doing is have this long running script create a XML file, which the web interface will display.

       

      The issue I am having is constructing the XML to post back to the server. I can read a file fine.

       

      var website = "mySillytest.com:80";
      var path = "/thingy/newXMLDocument.xml";
      
      
      reply = "";
      conn = new Socket;
      if (conn.open (website)) {
          conn.write ("GET "+path+" HTTP/1.0\n\n");    
          reply = conn.read(999999); 
          conn.close();
      }else{
          $.writeln ("NO CONNECTION");
          }
      
      $.writeln(reply);
      

       

      I'm just overwriting the same file newXMLDocument.xml all the time at the same location this one is been read from.

       

      I have to use "POST" in conn.write, but I'm unsure how to proceed from there.

      Any pointers would be welcome.

        • 1. Re: Socket - xml back to server
          Loic.Aigon Adobe Community Professional

          If it's on a same network why not simply write the file to a shared volume ?

           

          var log = function(data) {
            var f = File ( "/shared/volume/directory/log.xml" );
            f.encoding = "UTF-8";
            f.open('a');
            f.writeln ( data.toXMLString() );
            f.close();
          }
          
          
          var data = <data date="xxx" message="sdkljlqdjslk"/>
          
          
          log ( data );
          

           

          FWIW

           

          Loic

          Ozalto | Productivity Oriented - Loïc Aigon

          • 2. Re: Socket - xml back to server
            Vamitul Level 4

            the .write() method's parameter is a string. So you can either construct the xml in memory and pass it to the write method (conn.write(theXml.toXMLString()) or,if you have the xml in a file, you need to open that file, read it's contents (close it) and pass the content to the connection.

            However, Loic is right. If you can use a file, don't bother with the socket.

            Or, if you want to use the socket, then your web app should not try to look for a file, but just accept incoming connections from indesign.