webMethods

 View Only
Expand all | Collapse all

Shell script to execute wM service

  • 1.  Shell script to execute wM service

    Posted Tue February 13, 2024 09:02 AM

    I want to execute a webMethods service (i;e flow service or java service) using a shell script.

    With curl, I have something like this:
    curl -u user:password http://ip:port/invoke/linkToTheService.
    But it not fit my use case because it is based on http and I can not do a condition on the result to know if the script is successfully execute or not.

    Do anyone know how I can achieve my goal ?


    #Integration-Server-and-ESB
    #Service-Designer
    #webMethods
    #Command-Central


  • 2.  RE: Shell script to execute wM service

    Posted Tue February 13, 2024 11:59 AM

    Why do you say that? It is an HTTP call. In the script, you’ll want to check the HTTP status code. And depending upon the HTTP body returned by the service that is called, parse the response body as desired. The format of the response depends entirely on what the service does – by default it will return HTML. But can return XML, JSON, delimited data, etc.

    Side note: beware placing the user:password in the URL in a command-line. Anyone with the right access to the system can see that. There is a way to store credentials securely for curl to use. Refer to the curl docs on that.


    #Integration-Server-and-ESB
    #Command-Central
    #Service-Designer
    #webMethods


  • 3.  RE: Shell script to execute wM service

    Posted Tue February 13, 2024 01:12 PM

    Agree with @reamon ; all webMethods services are essentially lightweight HTTP APIs (We can argue if they are ReST or not). They can take XML / JSON input and can return XML / JSON output. You can capture the output in variable, parse it using jq or other tools to perform an action.

    I would be curious to understand what is your overall usecase? Normally, I have seen shell scripts invoking webMethods to perform routine maintenance tasks such as Disable Listener of MQ Adapter etc.


    #Integration-Server-and-ESB
    #Command-Central
    #Service-Designer
    #webMethods


  • 4.  RE: Shell script to execute wM service

    Posted Tue February 13, 2024 03:09 PM

    I’ll argue that they are not because, in one view of the world, there is no such thing as a REST API. :slight_smile:

    Roy Fielding has noted at various times that the “REST” label has been hijacked to mean something other than how he defined it. REST is an architectural style, having nothing to do with APIs per se. But as an industry, as we seem to do a lot, we took a word that had one meaning and applied it to something else which only vaguely resembles the original meaning. Now we use REST API (or just REST more so than not) to usually mean “JSON over HTTP” and argue about the “RESTfulness” of URLs. :slight_smile:

    I’m interested too – why use shell scripts/curl? If there is automation needed, do it in wM IS!


    #Integration-Server-and-ESB
    #Command-Central
    #Service-Designer
    #webMethods


  • 5.  RE: Shell script to execute wM service

    Posted Thu February 15, 2024 05:58 AM

    1- At the first place I was thinking doing the execution based on a number like 0 or 1 and not based on the http status code. Thank to point out the checking part. Yesterday, I’ve changed my code to check the http status code.

    2- Thank for the side note part. Actually I keep the credentials in the url for the testing part. Later I can remove it and use the secure way.


    #Command-Central
    #Integration-Server-and-ESB
    #webMethods
    #Service-Designer


  • 6.  RE: Shell script to execute wM service

    Posted Thu February 15, 2024 06:22 AM

    @CHIRAG & @reamon Here is my use case.

    We have many wM services that we don’t want to schedule using the internal wM Scheduler. In fact we use an external automatisation tool (i.e Control-M). When we use a web service, often we get a timeout issue. That is why we ideally want something that is not rely on http.

    So I want my sh script to call my wM services (i.e: flow service, java service) by not using http like it can be done with curl.

    I’ve checked the WmPublic package but I don’t get anything relevant that can help me achieve my goal. I’ve found the service pub.utils:executeOSCommand. But it is not helping me at this time.

    Any idea/direction on how I can achieve my goal ?


    #Service-Designer
    #Integration-Server-and-ESB
    #webMethods
    #Command-Central


  • 7.  RE: Shell script to execute wM service

    Posted Thu February 15, 2024 09:42 AM

    Did you try implementing an async service? Using terminal just to implement a scheduled service sounded like an overkill to me.

    You can also create a publishable document, and publish a document to invoke the time consuming process from a webservice, notify the client after publishing a document, and then notify again after the work is done.


    #Service-Designer
    #Command-Central
    #Integration-Server-and-ESB
    #webMethods


  • 8.  RE: Shell script to execute wM service

    Posted Thu February 15, 2024 10:58 AM

    In fact, the scheduling part is/will not be done with the terminal or a script. We have a tool name Control-M that will do it. The actual need is to execute a service in the sh script.


    #webMethods
    #Command-Central
    #Service-Designer
    #Integration-Server-and-ESB