Clarity PPM

Expand all | Collapse all

How to send and receive data through Invoke Action Web Service

Jump to Best Answer
  • 1.  How to send and receive data through Invoke Action Web Service

    Posted 02-28-2017 06:00 AM

    Hi CA experts!!!

     

    I would like to ask to all experts here, and hear some opinions too, about a task that we want to do in our project.

    We have another application (let's call it XIS) that need to display some of the CA Clarity data in their application. We provide some web services (Query and Objects) to deliver this data. Meanwhile, our projects in CA Clarity execute a process if a condition is verified, to catch data from another data sources (other databases). This process runs when the project is saved.

    The main problem here is, when the XIS is calling the web services Query or Object the data could be out-of-date. To solve this problem I'm think to call the Invoke Action web service. I already do some test and I already understand how to call this web service. But, my main question here is when I send data through request tag, how can I catch this values in the process, in this case in the gel script. For instance, my request is made using this XML

     

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:inv="http://www.niku.com/xog/InvokeAction">
       <soapenv:Header>
          <inv:Auth>
            <inv:Username>userXIS</inv:Username>
            <inv:Password>niku2017</inv:Password>
          </inv:Auth>
       </soapenv:Header>
       <soapenv:Body>
          <inv:Process>
             <code>process_invaction</code>
             <request>
              <projects>
               <project projectID="5584503">            
               </project>
              </projects>
             </request>
          </inv:Process>
       </soapenv:Body>
    </soapenv:Envelope>

    After making this call, I can see the process to be start and execute and finish with success, but I'm still need to catch the XML sent through the request XML tag (projectID value) to make the correct update in the database. How can I do this?

    I already though in another way too. In my research I saw that is possible to catch the current process instanceId using ${gel_processInstanceId}. The process has a xml_document associated. If it was possible catch this XML from a query, and the XML is the XML fragment sent through request XML tag, I think that I will be able to do the correct update in my project.

    Please, can anyone help me on this, explain how to catch the request XML in a gel script or if exist another way to to that?

     

    Many thanks,

    AB



  • 2.  Re: How to send data through Invoke Action Web Service

    Posted 02-28-2017 06:23 AM

    Not sure if I'm understanding the question, but in the initiated GEL script that is running against the project object, then the project id would be in variable ${gel_objectInstanceId}



  • 3.  Re: How to send data through Invoke Action Web Service

    Posted 02-28-2017 10:36 AM

    Hi. I'm initiating the process through InvokeAction web service (on demand), sending the ProcessId/ProcessCode in the tag code and other data in the request tag.

    The process definition does not have any object associated. So, the value returned by the ${gel_objectInstanceId} is -1.



  • 4.  Re: How to send data through Invoke Action Web Service

    Posted 02-28-2017 10:55 AM

    OK I misunderstood - so I think your question could be said as "how can I initiate a instance-specific process via the web-service", and the answer is you can't as such - see here for example ; Run Process linked to Object via Gel 

     

    However, what we can do is update the instance based on a web-service/XOG update (setting a dummy flag if needed), and then have a process in the application defined to auto-start on update which does whatever processing you need.

     

    (hope I'm understanding you now)



  • 5.  Re: How to send data through Invoke Action Web Service

    Posted 02-28-2017 11:43 AM

    Yes, you understood now. Sorry, if I'm not clear.

    But I can call the process using the web service. I already got it. My problem now is how to send or how to catch the XML fragment in the request tag in the gel script.

    I know that this part of the XML is received by the action, because if I put <gel:parse var="xmldoc"> in the gel script, the process stops with an error and running a query over the BPM_SESSION_DATA, I'm able to see this XML fragment in the BLOB. So, the main problem here is how to get the XML fragment request in the gel script.

    Using the another option (dummy flag, doing update), could be a risk for us, because if the third party application that will call the webservice, send a invalid data, a new project will be created or an updated will occur with invalida data.

     

    Thanks.



  • 6.  Re: How to send data through Invoke Action Web Service

    Posted 02-28-2017 11:53 AM

    Well I think you have to read the BLOB then, there isn't a "supported" way as far as I know. (might be tricky to do that (BLOB reads) in an on-demand system?).

     

    An alternative solution (if you are concerned about the message that an external web-service might send) might be to expose some other "thing" to the external web-service and trigger the application-side updates based on that other "thing" with appropriate security/validation. For example, allowing the external web-service to create requests for update (new instances of a custom object) - a PPM process triggered on create of that custom-object could then trigger the update on the real project-instance (if appropriate). Ugh!



  • 7.  Re: How to send data through Invoke Action Web Service

    Posted 02-28-2017 12:57 PM

    yeah.... the BLOB is generated only when occurs a error in gel script. So, I think that is not pretty solution.

    Your alternative sounds better to me, I will try.

     

    Many Thanks David.



  • 8.  Re: How to send data through Invoke Action Web Service
    Best Answer

    Posted 02-28-2017 01:15 PM

    In the GEL script you want to use the <gel:getDocument> tag to bring in the XML fragment contained within the <request> element of your request.

     

    Reference: https://docops.ca.com/ca-ppm/15-1/en/administration/reference/xml-open-gateway-xog-development/gel-tag-library-reference/gel-tag-library#GELTagLibrary-gel:getDocument-RequestingXMLDocuments

     

    You can then use the XML tags in GEL to parse/read the contents.



  • 9.  Re: How to send data through Invoke Action Web Service

    Posted 03-01-2017 05:28 AM

    Hi Nick.

     

    My first attempt was to use the <gel:getDocument> to reach the XML, but without success. Here are some attempts that I'm tried to catch the XML fragment inside the gel script:

     

    <gel:getDocument var="code"/>
    <gel:set select="$code/text()" var="x" asString="true"/>

    <gel:log level="info" category="XML Data code 1" message="${code}"/>
    <gel:log level="info" category="XML Data code 2" message="${x}"/>

    <gel:getDocument var="request"/>
    <gel:log level="info" category="XML Data request 1" message="${request}"/>
    <gel:log level="info" category="XML Data request 2" message="${request}/text()"/>
    <gel:log level="info" category="XML Data request 3" message="${request}//@projectID"/>

    <gel:getDocument var="projects"/>
    <gel:log level="info" category="XML Data projects 1" message="${projects}/project"/>

    the results in the log are:

    [XML Data code 1][#document: null]
    [XML Data code 2]     
    [XML Data request 1][#document: null]
    [XML Data request 2][#document: null]/text()     
    [XML Data request 3][#document: null]//@projectID   
    [XML Data projects 1][#document: null]/project     
    BPM-0546: Custom script has completed.

     

     

    I didn't understand yet how can I catch the XML fragment. I can see that a XML is created when I use <gel:getDocument> but how can I acces the "input data" sent in the request tag.

     

    Could you help me on this Nick?

    Thank you.



  • 10.  Re: How to send data through Invoke Action Web Service

    Posted 03-01-2017 09:18 AM

    Hi Nick.

    I already found the right way to catch the values from the request:

    1) Get the XML document (the var request keep the XML object)

    <gel:getDocument var="request"/>

    2) Use gel:set to retain the all necessary values:

    <gel:set select="$request//@projectID" var="projectID" asString="true"/>

     

    Thank you Nick, your help was very important!



  • 11.  Re: How to send and receive data through Invoke Action Web Service

    Posted 03-01-2017 09:38 AM

    Yes my apologies, I just updated the typo in my original reply to reflect it should be the <request> element and not the <code> one.

     

    I was just putting together an example before I followed-up, but I'm glad you got it sorted.

     

    Here was the example I made:

     

    Given:

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:inv="http://www.niku.com/xog/InvokeAction">
       <soapenv:Header>
          <inv:Auth>
             <inv:SessionID>5895070__49B9D831-E875-4D50-A68F-F886F4274A8E</inv:SessionID>
          </inv:Auth>
       </soapenv:Header>
       <soapenv:Body>
          <inv:Process>
             <code>ia</code>
             <request>
              <projects>
               <project projectID="5584503">           
               </project>
              </projects>
             </request>
          </inv:Process>
       </soapenv:Body>
    </soapenv:Envelope>

     

    And a GEL script of:

     

    <gel:script
      xmlns:core="jelly:core"
      xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary"
    >
    <gel:getDocument var="request" />
    <gel:set var="plain" asString="true" select="$request" />
    <gel:log level="INFO" category="doc">${plain}</gel:log>
    <gel:set asString="true" select="$request//projects/project/@projectID" var="prj_id" />
    <gel:log level="INFO" category="prj">ID = ${prj_id}</gel:log>
    </gel:script>

     

    Here were the results: