4 Replies Latest reply on May 13, 2008 5:06 PM by (SusanDoan)

    Call ID Server from remote machine using AS

    Level 1
      Hello,
      I read all documentation but I haven't find any example about how to call IDServer from remote machine using AppleScript using SOAP or others technologies
      I want to create a palette using Xcode and AppleScript Studio to pilote ID Server from remote machines.
      Does anyone have ideas or samples on how to accomplish this task?

      Stefano
        • 1. Re: Call ID Server from remote machine using AS
          Level 1
          Maybe the easiest way to do this is to modify the c++ sampleclient that comes with the InDesign Products SDK.  For CS3, the sampleclient runs only javascript, but it can be easily modified to run applescript as well.  <br /><br />To do this:<br />* open the sampleclient project at: <br />    <SDK>/build/mac/prj/SampleClient.xcodeproj<br /><br />* modify main.cpp (near line 262) to change the scriptLanguage parameter to "applescript" as needed:<br /><br />    IDSP__RunScriptParameters runScriptParams;<br />    runScriptParams.scriptArgs = &script_args;<br />    runScriptParams.scriptLanguage = "javascript";<br /><br />    // check file extension for .applescript<br />    const regex appleScript("^.+\\.(applescript)", regbase::icase);<br />    match_results<string::const_iterator> match;<br />    if (regex_match(script, match, appleScript, match_default)){<br />        runScriptParams.scriptLanguage = "applescript";<br />    }<br /><br />* build the project<br /><br />* run your new sampleclient app from the command line:<br />    sampleclient myApplescript.applescript -host 123.45.56.789:1234<br /><br />For more on sampleclient, read:<br /><SDK>/docs/guides/indesign-server-test-client.pdf<br /><IDS-SDK>/docs/guides/Intro to InDesign CS3 Server.pdf<br /><br />Another option:<br />There is a php sample client contained in the InDesign CS3 Server SDK.<br /><br />Both SDKs mentioned can be downloaded from:  http://www.adobe.com/devnet/indesign/<br /><br />Susan
          • 2. Re: Call ID Server from remote machine using AS
            Dirk Becker  Level 4
            As I understand this thread, Stefano asks how to use an AppleScript client machine to talk to a remote InDesign Server - via SOAP or other means, while the answer was more along how to invoke an AppleScript server side program.

            A quick google search took me to this page:

            http://developer.apple.com/documentation/AppleScript/Conceptual/soapXMLRPC/chapter2/chapte r_2_section_3.html

            It describes how to send SOAP requests from within AppleScript.
            I doubt though, whether SOAP is the best approach. AppleScript itself is already prepared for remote execution, and the InDesign server (on OSX) should be able to handle AppleEvents independently from originating machine. So this is more a question how to allow remote Apple Events at all, and we can forget about SOAP.

            Stefano, have you tried the basics such as enabling Remote Apple Events in the Sharing page of the System Preferences? The setting might have been reset with an 10.5 upgrade! Are all firewalls between the boxes open for the relevant ports? Ever talked to any other Application of a different machine?

            First, run this script locally. Here it takes ages until the expected result is delivered, probably something to add to the server group's QA tests :)

            using terms from application "InDesignServer"
            tell application "InDesignServer" of machine "eppc://127.0.0.1"
            get name of documents
            end tell
            end using terms from

            Next is the remote variant. CS3 Server is on MacTel Tiger, the client is my CS2 development machine, a G5 Panther.
            After several failures, I completely disable the firewall on both machines, the default settings via the sharing panel turned out insufficient. Beyond that, don't ask me how to solve other kinds of not working networking, probably you find better answers - what port to add - in Apple's forums ...

            using terms from application "Adobe InDesign CS2"
            tell application "InDesignServer" of machine "eppc://username:password@192.168.178.24"
            get name of documents
            end tell
            end using terms from

            Remains the question how to move the terminology to the client box. Probably it is enough to store your scripts as compiled script, and the development machine must have either InDesign (as above) or InDesignServer installed.

            Dirk
            • 3. Re: Call ID Server from remote machine using AS
              Level 1
              Hi Susan and Dirk,

              thanks for all suggestions.
              I prefer to use the Susan method because using tell application "InDesignServer" of machine "eppc://..." require authentication.
              Just other two questions for Susan: I succesfully modified and compiled the simpleClient Xcode project but I discovered that the compiled app requires some additional components like libboost_regex-mt-1_33.dylib.
              I mean that If I copy only the Unix executable called "testclient" in another place and run from terminal I receive:
              dyld: Library not loaded: @executable_path/libboost_regex-mt-1_33.dylib
              Referenced from: /Users/stefano/Desktop/testclient
              Reason: image not found
              Trace/BPT trap

              Otherwise if the path of executable is the original (where in the same directory there are many additional files) all works good.

              The second very important question is that returned result from remote script is a "little" different from default AppleScript result of returned data.
              Example:

              "Script result (LIST, 2):
              (long): 10
              (std__string): hello"

              So I need to parse it or there is same way for return the data from ID Server like AppleScript usually do?

              Thanks in advance

              Stefano
              • 4. Re: Call ID Server from remote machine using AS
                Level 1
                Hi Stefano,

                To have SampleClient run on another machine, you are correct, you need to also copy the necessary dylib files.

                As far as getting script results using SampleClient, you would either need to edit the C++ code to perform the desired action based on the result, or you can do this using AppleScript.

                1) Create a wrapper AppleScript that calls InDesign Server's "doScript" (uses ScriptArgs to get path of script to run):

                tell application "InDesignServer"
                tell script args
                set scriptPath to get value name "path"
                end tell
                set regularArgs to {"first argument", "second argument"}
                set scriptReturnValue to do script scriptPath language applescript language with arguments regularArgs
                end tell
                -- do something with the script's return value...
                scriptReturnValue -- pass the value back to SampleClient

                2) Your script will now use the "arguments" parameter instead of ScriptArgs:

                tell application "InDesignServer"
                set arg1 to item 1 of arguments
                set arg2 to item 2 of arguments
                set returnValue to "arg1 = " & arg1 & ", arg2 = " & arg2
                end tell
                returnValue -- pass the value back to the wrapper AppleScript

                3) And here's your SampleClient command line (note posix path style is required for the path argument):

                sampleclient -host localhost:12345 /Volumes/HD2/ServerTestFiles/doScript.applescript path="HD2:ServerTestFiles:regularArgs.applescript"

                Hope this helps.
                Susan