Knowledge Base > Automation Engine and Target Systems > Java EE/JMX > Send a SOAP Message using an MBean

Sending an SOAP Message with an MBean

Below is an example for an SOAP message which polls stock prices.

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<ns1:getQuote soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns1="urn:xmethods-delayed-quotes">
<symbol xsi:type="xsd:string">IBM</symbol>
</ns1:getQuote></soapenv:Body>
</soapenv:Envelope>

The following SOAP actionActions are predefined building blocks for recurring activities. They are commonly used for managing third party systems or in deployment scenarios. should be used to send the SOAP message: "urn:xmethods-delayed-quotes#getQuote".  

URL of the webservice: http://services.xmethods.net/soap

An MBean can be used to send this SOAP message. This MBean requires at least Java version 5. Add  the MBean to the agentA program that enables the de-centralized execution of processes (such as deployments) on target systems (computers or business solutions) or a service that provides connectivity to a target system (such as for databases or middleware). An agent is also an object type in the Automation Engine. [Formerly called "Executor."] See also: host's classpath:

  1. Copy the file soapmbean.jar into the folderTop level entities such as Environment, Deployment Target, Activity, … are stored in folders. The permissions a user has on an entity depend on the permissions that are set on the folder for the entities. of the JMX agent.
  2. Start the JMX agent with the file soapmbean.jar in the classpath.
    java -cp soapmbean.jar;ucxjjmx.jar com/uc4/ex/jmx/UCXJMX

Create a JMX jobAn Automation Engine object type for a process that runs on a target system. and insert the following line in the Process tab:

JMX_CREATE_MBEAN EXISTS="IGNORE",CLASSNAME="com.uc4.ex.jmx.soap.SOAP",NAME="uc4.com:name=SOAP"

Start the job. The MBean "SOAP" is now listed in the MBean Browser.

In the next step, determine the JCL for using the SOAP MBean:

JMX_CREATE_MBEAN EXISTS="IGNORE",CLASSNAME="com.uc4.ex.jmx.soap.SOAP",NAME="uc4.com:name=SOAP"
JMX_COMPOSITE_ADD KEY="1",VALUE='<?xml version="1.0" encoding="UTF-8"?>',NAME="s"
JMX_COMPOSITE_ADD KEY="2",VALUE='<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" ',NAME="s"
JMX_COMPOSITE_ADD KEY="3",VALUE='xmlns:xsd="http://www.w3.org/2001/XMLSchema" ',NAME="s"
JMX_COMPOSITE_ADD KEY="4",VALUE='xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">',NAME="s"
JMX_COMPOSITE_ADD KEY="5",VALUE="<soapenv:Body><ns1:getQuote ",NAME="s"
JMX_COMPOSITE_ADD KEY="6",VALUE='soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" ',NAME="s"
JMX_COMPOSITE_ADD KEY="7",VALUE='xmlns:ns1="urn:xmethods-delayed-quotes">',NAME="s"
JMX_COMPOSITE_ADD KEY="8",VALUE='<symbol xsi:type="xsd:string">IBM</symbol>',NAME="s"
JMX_COMPOSITE_ADD KEY="9",VALUE="</ns1:getQuote></soapenv:Body></soapenv:Envelope>",NAME="s"
JMX_INVOKE OPERATIONNAME="sendSOAP",MBEAN="uc4.com:name=SOAP",PARAMS='s,"urn:xmethods-delayed-quotes#getQuote",http://services.xmethods.net/soap'

The first line ensures that the MBean exists or loads it if necessary. The statements JMX_COMPOSITE_ADD insert the SOAP message line by line with the parameter KEY= containing the line number. After the SOAP message has been composed, it is assigned to the operation "sendSOAP" (JMX_INVOKE) as its first parameter. The second parameter contains the SOAP action, and the third one  the URL to which the SOAP request should be sent.

Execute the job. The job reportA report provides more detailed information about a task's execution or a component. shows the response message.

An XPath expression can be used to read an individual value. Do so by inserting a new scriptA particular Automation Engine object type. line using the script element JMX_COMPOSITE_ADD with the statement "XPATH" for KEY= and the searched value for VALUE= (see second script line). The script now looks as shown below:

JMX_CREATE_MBEAN EXISTS="IGNORE",CLASSNAME="com.uc4.ex.jmx.soap.SOAP",NAME="uc4.com:name=SOAP"
JMX_COMPOSITE_ADD KEY="XPATH",VALUE="//Result",NAME="s"
JMX_COMPOSITE_ADD KEY="1",VALUE='<?xml version="1.0" encoding="UTF-8"?>',NAME="s"
JMX_COMPOSITE_ADD KEY="2",VALUE='<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" ',NAME="s"
JMX_COMPOSITE_ADD KEY="3",VALUE='xmlns:xsd="http://www.w3.org/2001/XMLSchema" ',NAME="s"
JMX_COMPOSITE_ADD KEY="4",VALUE='xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">',NAME="s"
JMX_COMPOSITE_ADD KEY="5",VALUE="<soapenv:Body><ns1:getQuote ",NAME="s"
JMX_COMPOSITE_ADD KEY="6",VALUE='soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" ',NAME="s"
JMX_COMPOSITE_ADD KEY="7",VALUE='xmlns:ns1="urn:xmethods-delayed-quotes">',NAME="s"
JMX_COMPOSITE_ADD KEY="8",VALUE='<symbol xsi:type="xsd:string">IBM</symbol>',NAME="s"
JMX_COMPOSITE_ADD KEY="9",VALUE="</ns1:getQuote></soapenv:Body></soapenv:Envelope>",NAME="s"
JMX_INVOKE OPERATIONNAME="sendSOAP",MBEAN="uc4.com:name=SOAP",PARAMS='s,"urn:xmethods-delayed-quotes#getQuote",http://services.xmethods.net/soap'

Based on the sample script, the job report now shows a value.

Parts of the SOAP message can also be supplied with values via script variables. The following example reads a value via a :READ mask:

Pre-Process tab:

:READ &SYMBOL#,"IBM,SAP,ORCL","Please choose one","IBM"

Process tab:

The script variableA placeholder for a value within a script. &SYMBOL# is used in the 10th line:

JMX_CREATE_MBEAN EXISTS="IGNORE",CLASSNAME="com.uc4.ex.jmx.soap.SOAP",NAME="uc4.com:name=SOAP"
JMX_COMPOSITE_ADD KEY="XPATH",VALUE="//Result",NAME="s"
JMX_COMPOSITE_ADD KEY="1",VALUE='<?xml version="1.0" encoding="UTF-8"?>',NAME="s"
JMX_COMPOSITE_ADD KEY="2",VALUE='<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" ',NAME="s"
JMX_COMPOSITE_ADD KEY="3",VALUE='xmlns:xsd="http://www.w3.org/2001/XMLSchema" ',NAME="s"
JMX_COMPOSITE_ADD KEY="4",VALUE='xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">',NAME="s"
JMX_COMPOSITE_ADD KEY="5",VALUE="<soapenv:Body><ns1:getQuote ",NAME="s"
JMX_COMPOSITE_ADD KEY="6",VALUE='soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" ',NAME="s"
JMX_COMPOSITE_ADD KEY="7",VALUE='xmlns:ns1="urn:xmethods-delayed-quotes">',NAME="s"
JMX_COMPOSITE_ADD KEY="8",VALUE='<symbol xsi:type="xsd:string">&SYMBOL#</symbol>',NAME="s"
JMX_COMPOSITE_ADD KEY="9",VALUE="</ns1:getQuote></soapenv:Body></soapenv:Envelope>",NAME="s"
JMX_INVOKE OPERATIONNAME="sendSOAP",MBEAN="uc4.com:name=SOAP",PARAMS='s,"urn:xmethods-delayed-quotes#getQuote",http://services.xmethods.net/soap'

 

 


Automic Documentation - Tutorials - Automic Blog - Resources - Training & Services - Automic YouTube Channel - Download Center - Support

Copyright © 2016 Automic Software GmbH