1 2 Previous Next 25 Replies Latest reply on Mar 17, 2011 8:38 AM by AS2E

    Custom Web View and PHP

    AS2E Enthusiast

      Hello everyone,


      I'd like to run PHP code on my custom web view but I don't know how to install it. The problem is than I don't even know which web server Orchestrator is using. I thought it was Apache but I can't find corresponding files. Could anyone help me to implement this functionality?



        • 1. Re: Custom Web View and PHP
          Jinnie Enthusiast
          VMware Employees

          It runs on JBoss at the moment.


          Quick googling shows some topics on JBoss modules for PHP. But I have not tried it.

          And I am not really sure what is the chanse of successful mix between php and the usual tapesty/dojo environment of the webviews.

          • 2. Re: Custom Web View and PHP
            tschoergez Master
            VMware EmployeesvExpertUser Moderators


            PHP directly in Orchestrator? Forget it (sorry)!


            Even if you manage it to run PHP on JBoss, there will be no direct integration into the Orchestrator-objects, as Jinnie mentioned.


            The only way I see is to use a SOAP-client-library for PHP on an external webserver. Maybe the python-client for the Orchestrator-Webservice will help to get an idea: http://labs.vmware.com/flings/pyvco


            (If you are new to the standard vco-webviews: It's hard to get started with them, and their future is VERY uncertain, so maybe focussing on another technology based on the Webservice-API is the better way)




            • 3. Re: Custom Web View and PHP
              AS2E Enthusiast

              Well, seems to be pretty complicated. There might be another solution I hope. After running a workflow I'd like to check if it was successfull. I'm talking about very short workflows like restarting or resetting virtual machines. In case these workflows fail, this mostly means than the user don't has the nessecary rights and I'd like to display adequate error message.


              I managed it to select the necessary information out of the Orchestrator database. Now I though about using PHP for reading out these data. Are there other possibilities for doing this?

              • 4. Re: Custom Web View and PHP
                tschoergez Master
                vExpertUser ModeratorsVMware Employees

                Reading the information from the database will work surely. And if you really read-only, I see no danger for corruptin anything. BUT: The official statement of VMware will be: The database schema is not part of the API, so it is subject to change even in minor updates.

                So have to QA your database reader after every vCO-patch, because the database layout may have changed.


                For the use case you mentioned the way via webservice-API is not too complicated, I guess (calling workflows with multiple input is much more complicated). Here you only find the workflow and its past token, so only a few POST-values for the API call.


                There might be another way: Can you create an action inside vCO which returns exactly the information you need?

                Then is should be possible to call this action via a direct webview-link without any webservice-stuff. (You can find an example on page 307 in the developer guide).


                I might find some time to create an concrete example on weekend...




                1 person found this helpful
                • 5. Re: Custom Web View and PHP
                  AS2E Enthusiast

                  I tried to create an action which should return the needed infomation. But now I have trouble calling the action in my webview.  I tried something like the following but of course this doesn't work because there is no system folder in my web view root folder. I'm a little confused about this. Do I have to create these folders manually? What do I have to put into the action.html file?


                  <script type="text/javascript" language="JavaScript">
                  var sysstat = .system/execute/action/action.html?action=GetTokenState&actionParameters=attribute:ResetVM&actionParameters=ResetVM;

                  • 6. Re: Custom Web View and PHP
                    tschoergez Master
                    vExpertUser ModeratorsVMware Employees


                    the system/execute/action.... is not a old-fashioned static html-file, it is a mapped method of the Tapestry-component in background. Comparable to a RESTful Web-Service. So there is no need to create the folder or copy any files.

                    Just make sure that the webview is published and has an Attribute "GetTokenState" (Type: Action) in your case. Then the full link to call the action should be http://your-vco-server:8282/vmo/yourwebviewname/system/execute/action/action.html?action=GetTokenState......



                    1 person found this helpful
                    • 7. Re: Custom Web View and PHP
                      AS2E Enthusiast



                      How can I catch the the value the action I created returns? Don't I have to use a variable the value is going to be saved in?



                      • 8. Re: Custom Web View and PHP
                        tschoergez Master
                        User ModeratorsvExpertVMware Employees

                        Did it work with the link-example in my last post?

                        (I get a strange "String index out of range: -1" error when I try)


                        But if your read further in the dev guide, on page 308 second half there is another "Run an Action from a URL" chapter (seems to be a copy&past error in the docs).

                        With the link-structure like


                        it worked for me.


                        The result is direct the return of the called Action. If this return is a complex data type, the result will be in JSON-syntax.

                        You could now process this in your web applicaiton. A short google found an example:


                        (its in German, but I don't think thats a problem for you :-) )


                        If you want, I can put together a complete example-package in vCO for you....




                        • 9. Re: Custom Web View and PHP
                          AS2E Enthusiast

                          The first example you posted didn't work for me too. The second one at least doesn't return an error. I'm using the following link:




                          I created web view attributes for the GetTokenState action and the RestartVM workflow. This link displays nothing else than a "null" in the top left edge of the browser. I think there should be the value the action returns instead.


                          The action itself definitely works. For testing I created a workflow which calls the action and I added a System.log which puts out the returned value. This works fine. The action only returns the tokens state so I don't think that's a complex data type. It's just a string.


                          Here's my action in case you need it.


                          var retList = new Array();

                          if (runningWF != null) {

                          var tokens = runningWF.executions;
                          if(tokens != null){
                            for(var jj=0; jj<tokens.length; jj++){
                              retList.push( tokens[jj] );

                          function compare( token1, token2 )  {
                          var time1 = token1.startDate;
                          var time2 = token2.startDate;
                          if ( time1 < time2 )  {
                            return -1;
                          if ( time1 > time2 )  {
                            return 1;
                          return 0;

                          retList.sort( compare ).reverse();
                          var state = retList[0].state;
                          System.log("Current State: "+state);

                          return state;

                          • 10. Re: Custom Web View and PHP
                            tschoergez Master
                            User ModeratorsvExpertVMware Employees


                            Your Action worked for me:

                            08-03-2011 09-17-45.png


                            Don't forget to set the return-Type of your Action to String:

                            08-03-2011 09-19-07.png



                            BTW: I like the line "retList.sort( compare ).reverse();"... very smart usage of JavaScript-Power ... I just don't want to maintain it two years later .



                            • 11. Re: Custom Web View and PHP
                              AS2E Enthusiast

                              I probably didn't set the return type correctly. Could you fix the pictures attached so I can how it worked for you? Something with the linking went wrong, I think.


                              btw. I copied the "retList.sort( compare ).reverse();" from another action. If something changes in a new version and it won't work anymore, I'll still be able to copy the changes.

                              • 12. Re: Custom Web View and PHP
                                AS2E Enthusiast

                                I figured out where to set the return type. Now it works. For writing my the result into a variable, would you agree than the easiest way is to write it into a file first and read out that file afterwards? I can't find any hints it the documentation than there is a direct way too. Do you know where vCO saves that file? It doesn't seem to be possible to enter a path, at least I didn't figure out a way it works.


                                Here's the link I'm using right know:


                                • 13. Re: Custom Web View and PHP
                                  tschoergez Master
                                  User ModeratorsvExpertVMware Employees


                                  first of all: Another try with the pictures...



                                  aah, here we go: no space in the filename allowed.... "again what learned"


                                  For the result: it comes back directly via http to the one who executed the link, so no need to save it to a file!?


                                  If you want to save some information to a file, this is done locally on the vCO-server, with the FileWriter-objects in javascript. (See an example in the XML-related workflows of the included library). If you want to access local files on the vCO-server, also don't forget to set the js-io-rights.conf (=> vCO-Admin guide)...


                                  do you call the action link from another PHP-based website?




                                  • 14. Re: Custom Web View and PHP
                                    AS2E Enthusiast

                                    Yes, that's how it looks in my environment too now. The problem I actually have is than the result comes back directly via http. Depending on the actions result I want to forward the user either to website A or website B. But for realizing that, I need the actions result in a variable (for the if-statement). I didn't found any hints in the developer's guide than it's possible to save the result directly into a variable, but on page 308 is a chapter "Writing Action Results to a File". That's why I thougt the easiest way to save the result in a variable is by writing it to a file first, and read out the file after. My problem now is, than there's nowhere stated where vCO saves that file. I can enter a filename and it work's whitout any errors, but when I search for this file on the server afterwards, I can't find it.


                                    You mean when I want to write something to file I have to do that inside the action? I don't had that idea yet but I'll try on Monday. That may work. Thanks.

                                    1 2 Previous Next