Rule mediator just pass the values extracted from the SOAP envelope, the Message Context, the registry to the rule engine and let to rule engine to take decision. Rule mediator defines the inputs (with in input tag) and these are used when computing values for binding to rule engine. A input tells how to, what and from where get the values .With in rule engine , using name attributes in the input definition , the corresponding value can be accessed . Any inputs values can only be accessed through the provided abstraction org.wso2.rule.Inputs and it only expose get(name) method . If you want to set any output value (consider as return values from rule engine) , there is a provided abstraction org.wso2.rule.Outputs and it only expose put(key,value) method. If you want to set return values from the rule engine back to the message context or to the SOAP envelope , then ,you have to use output in the rule mediator definition . A output tells how to ,what and to where set the return values.There is a special output value called 'execute_children' , this is used to indicate, after retuning back from the rule engine , whether child mediators inside the rule mediator should be executed or not. if the value is 'true' ,then if there are any child mediators , then those would be executed . For any other value in the 'execute_children', avoids the execution of child mediators. Then,what happens is , just pass the control to the next sibling mediator.
<!-- Simple rule based routing of messages - same as filter mediator --> <definitions xmlns="http://ws.apache.org/ns/synapse"> <in> <rule> <configuration xmlns="http://www.wso2.org/products/wso2commons/rule"> <ruleSource> <package name="SimpleRoutingRules" xmlns="http://drools.org/drools-5.0" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:schemaLocation="http://drools.org/drools-5.0 drools-4.0.xsd"> <import name="org.apache.synapse.MessageContext"/> <import name="org.wso2.rule.Inputs"/> <import name="org.wso2.rule.Outputs"/> <rule name="Invoke IBM "> <lhs> <pattern object-type="MessageContext" identifier="mc"> </pattern> <pattern object-type="Inputs" identifier="inputs"> </pattern> <pattern object-type="Outputs" identifier="outputs"> </pattern> <eval>((String)inputs.get("symbol")).equals("IBM")</eval> </lhs> <rhs> outputs.put("execute_children","true"); </rhs> </rule> </package> </ruleSource> <input name="symbol" expression="//m0:getQuote/m0:request/m0:symbol" xmlns:m0="http://services.samples" type="string"/> </configuration> <childMediators> <send> <endpoint> <address uri="http://localhost:9000/services/SimpleStockQuoteService"/> </endpoint> </send> <drop/> </childMediators> </rule> </in> <out> <send/> </out> </definitions>
Objective: Introduction to simple rule based routing
Prerequisites:
Start the Synapse configuration numbered 600: (i.e. ./wso2esb-samples.sh -sn
600)
Start the Axis2 server and deploy the SimpleStockQuoteService if not already deployed.
Run the client as
ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/
Or as
ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/ -Dsymbol=IBM
Then, you will get stock quote price in client side.
In this sample , with in the rule mediator , the value which is extracted from SOAP envelope using XPath '//m0:getQuote/m0:request/m0:symbol' and set it with key 'symbol' so that it can be accessed from inputs.get("symbol").
With in the rule script , in eval conditions , check the inputs.get("symbol") is equals to the 'IBM' . If the condition is evaluated to the boolean true , the sets the outputs.put("execute_children","true"); to indicates it is need to executes the child mediator of rule mediator.
Now use following commands
ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/ -Dsymbol=SUN
and
ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/ -Dsymbol=MSFT
Then , you will get errors . This is because , 'symbol' is not equal to "IBM".
<!-- Simple rule based routing of messages - same as filter mediator --> <<definitions xmlns="http://ws.apache.org/ns/synapse"> <!-- the SimpleURLRegistry allows access to a URL based registry (e.g. file:/// or http://) --> <registry provider="org.wso2.carbon.mediation.registry.ESBRegistry"> <!-- the root property of the simple URL registry helps resolve a resource URL as root + key --> <parameter name="root">file:repository/samples/resources/</parameter> <!-- all resources loaded from the URL registry would be cached for this number of milli seconds --> <parameter name="cachableDuration">15000</parameter> </registry> <localEntry key="rule-script-key" src="file:repository/samples/resources/rule/simple_rule_base.xml"/> <in> <rule> <configuration xmlns="http://www.wso2.org/products/wso2commons/rule"> <ruleSource key="rule-script-key"/> <input name="symbol" expression="//m0:getQuote/m0:request/m0:symbol" xmlns:m0="http://services.samples" type="string"/> </configuration> <childMediators> <send> <endpoint> <address uri="http://localhost:9000/services/SimpleStockQuoteService"/> </endpoint> </send> <drop/> </childMediators> </rule> </in> <out> <send/> </out> </definitions>
<package name="SimpleRoutingRules" xmlns="http://drools.org/drools-5.0" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:schemaLocation="http://drools.org/drools-5.0 drools-4.0.xsd"> <import name="org.apache.synapse.MessageContext"/> <import name="org.wso2.rule.Inputs"/> <import name="org.wso2.rule.Outputs"/> <rule name="Invoke IBM "> <lhs> <pattern object-type="MessageContext" identifier="mc"> </pattern> <pattern object-type="Inputs" identifier="inputs"> </pattern> <pattern object-type="Outputs" identifier="outputs"> </pattern> <eval>((String)inputs.get("symbol")).equals("IBM")</eval> </lhs> <rhs> outputs.put("execute_children","true"); </rhs> </rule> </package>
Objective: Introduction to simple rule based routing
Prerequisites:
Start the Synapse configuration numbered 601: (i.e. ./wso2esb-samples.sh -sn
601)
Start the Axis2 server and deploy the SimpleStockQuoteService if not already
deployed
Please tests this sample same as above (600) sample because this has same functionality as above one.
<!-- Simple rule based routing of messages - same as filter mediator --> <!-- The use of Drools native language --> <definitions xmlns="http://ws.apache.org/ns/synapse"> <!-- the SimpleURLRegistry allows access to a URL based registry (e.g. file:/// or http://) --> <registry provider="org.wso2.carbon.mediation.registry.ESBRegistry"> <!-- the root property of the simple URL registry helps resolve a resource URL as root + key --> <parameter name="root">file:repository/samples/resources/</parameter> <!-- all resources loaded from the URL registry would be cached for this number of milli seconds --> <parameter name="cachableDuration">15000</parameter> </registry> <localEntry key="rule-script-key" src="file:repository/samples/resources/rule/simple_rule_base.drl"/> <in> <rule> <configuration xmlns="http://www.wso2.org/products/wso2commons/rule"> <ruleSource key="rule-script-key" sourceFormat="drl"/> <ruleSet> <creation> <property name="source" value="drl"/> </creation> </ruleSet> <input name="symbol" expression="//m0:getQuote/m0:request/m0:symbol" xmlns:m0="http://services.samples" type="string"/> </configuration> <childMediators> <send> <endpoint> <address uri="http://localhost:9000/services/SimpleStockQuoteService"/> </endpoint> </send> <drop/> </childMediators> </rule> </in> <out> <send/> </out> </definitions>
<drl> <![CDATA[ package SimpleRoutingRules; import org.apache.synapse.MessageContext; import org.wso2.rule.Inputs; import org.wso2.rule.Outputs; rule InvokeIBM when inputs : Inputs() outputs : Outputs() eval( ((String)inputs.get("symbol")).equals("IBM") ) then outputs.put("execute_children","true"); end ]]> </drl>
Objective: Introduction to simple rule based routing (Using Drools native language )
Prerequisites:
Start the Synapse configuration numbered 602: (i.e. ./wso2esb-samples.sh -sn
602)
Start the Axis2 server and deploy the SimpleStockQuoteService if not already
deployed
Please tests this sample same as sample 600 because this has same functionality as it.
<!-- Advance rule based routing - Switching routing decision from rules --> <definitions xmlns="http://ws.apache.org/ns/synapse"> <!-- the SimpleURLRegistry allows access to a URL based registry (e.g. file:/// or http://) --> <registry provider="org.wso2.carbon.mediation.registry.ESBRegistry"> <!-- the root property of the simple URL registry helps resolve a resource URL as root + key --> <parameter name="root">file:repository/samples/resources/</parameter> <!-- all resources loaded from the URL registry would be cached for this number of milli seconds --> <parameter name="cachableDuration">15000</parameter> </registry> <localEntry key="rule-script-key" src="file:repository/samples/resources/rule/advanced_rule_base.xml"/> <sequence name="ibmSequence"> <send> <endpoint> <address uri="http://localhost:9000/services/SimpleStockQuoteService"/> </endpoint> </send> </sequence> <sequence name="myFaultHandler"> <makefault> <code value="tns:Receiver" xmlns:tns="http://www.w3.org/2003/05/soap-envelope"/> <reason expression="get-property('ERROR_MESSAGE')"/> </makefault> <property name="RESPONSE" value="true"/> <header name="To" expression="get-property('ReplyTo')"/> <send/> </sequence> <sequence name="sunSequence" onError="myFaultHandler"> <send> <endpoint> <address uri="http://localhost:9009/services/NonExistentStockQuoteService"/> </endpoint> </send> <drop/> </sequence> <sequence name="msftSequence" onError="myFaultHandler"> <send> <endpoint> <address uri="http://bogus:9000/services/NonExistentStockQuoteService"/> </endpoint> </send> <drop/> </sequence> <in> <rule> <configuration xmlns="http://www.wso2.org/products/wso2commons/rule"> <ruleSource key="rule-script-key"/> <input name="ibmSeq" key="ibmSequence" type="sequence"/> <input name="sunSeq" key="sunSequence" type="sequence"/> <input name="msftSeq" key="msftSequence" type="sequence"/> <input name="symbol" expression="//m0:getQuote/m0:request/m0:symbol" xmlns:m0="http://services.samples" type="string"/> </configuration> </rule> <drop/> </in> <out> <send/> </out> </definitions>
<package name="AdvancedRoutingRules" xmlns="http://drools.org/drools-5.0" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:schemaLocation="http://drools.org/drools-5.0 drools-4.0.xsd"> <import name="org.apache.synapse.MessageContext"/> <import name="org.wso2.rule.Inputs"/> <import name="org.wso2.rule.Outputs"/> <import name="org.apache.synapse.Mediator"/> <rule name="Invoke IBM "> <lhs> <pattern object-type="MessageContext" identifier="mc"> </pattern> <pattern object-type="Inputs" identifier="inputs"> </pattern> <pattern object-type="Outputs" identifier="outputs"> </pattern> <eval>((String)inputs.get("symbol")).equals("IBM")</eval> </lhs> <rhs> ((Mediator)inputs.get("ibmSeq")).mediate(mc); </rhs> </rule> <rule name="Invoke SUN "> <lhs> <pattern object-type="MessageContext" identifier="mc"> </pattern> <pattern object-type="Inputs" identifier="inputs"> </pattern> <pattern object-type="Outputs" identifier="outputs"> </pattern> <eval>((String)inputs.get("symbol")).equals("SUN")</eval> </lhs> <rhs> ((Mediator)inputs.get("sunSeq")).mediate(mc); </rhs> </rule> <rule name="Invoke MFST "> <lhs> <pattern object-type="MessageContext" identifier="mc"> </pattern> <pattern object-type="Inputs" identifier="inputs"> </pattern> <pattern object-type="Outputs" identifier="outputs"> </pattern> <eval>((String)inputs.get("symbol")).equals("MSFT")</eval> </lhs> <rhs> ((Mediator)inputs.get("msftSeq")).mediate(mc); </rhs> </rule> </package>
Objective: Advance rule based routing - Switching routing decision according to the rules - Rule mediator as Switch mediator.
Prerequisites:
Start the Synapse configuration numbered 603: i.e. (i.e. ./wso2esb-samples.sh
-sn 603)
Start the Axis2 server and deploy the SimpleStockQuoteService if not already deployed
This sample shows how can rule mediator act as Switch mediator. In this sample, the use of input with type 'sequence' is being introducing. The type 'sequence' indicates the synapse sequences. This enables to use defined sequences (reference or in-lined) with in rule script.
In rule script , there are three cases each for 'IBM','SUN' and 'MSFT'. When condition is match , then corresponding rule will be got fire.
Invoke IBM rule by running client as
ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/
You will get stock quote price successfully
Then invoke SUN rule by running client as
ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/ -Dsymbol=SUN
Then will get
<soapenv:Fault xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><faultcode>soapenv:Server</faultcode><faultstring>java.net.ConnectException: Connection refused</faultstring><detail /></soapenv:Fault>
Then invoke MSFT rule by running client as
ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/ -Dsymbol=MSFT
Then will get
<soapenv:Fault xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><faultcode>soapenv:Server</faultcode><faultstring>java.net.UnknownHostException: bogus</faultstring><detail /></soapenv:Fault>
<!-- Simple rule based transformation (changing message ) --> <definitions xmlns="http://ws.apache.org/ns/synapse"> <!-- the SimpleURLRegistry allows access to a URL based registry (e.g. file:/// or http://) --> <registry provider="org.wso2.carbon.mediation.registry.ESBRegistry"> <!-- the root property of the simple URL registry helps resolve a resource URL as root + key --> <parameter name="root">file:repository/samples/resources/</parameter> <!-- all resources loaded from the URL registry would be cached for this number of milli seconds --> <parameter name="cachableDuration">15000</parameter> </registry> <localEntry key="rule-script-key" src="file:repository/samples/resources/rule/always_ibm.xml"/> <in> <rule> <configuration xmlns="http://www.wso2.org/products/wso2commons/rule"> <ruleSource key="rule-script-key"/> <input name="symbol" expression="//m0:getQuote/m0:request/m0:symbol" xmlns:m0="http://services.samples" type="string"/> <output name="symbol" expression="//m0:getQuote/m0:request/m0:symbol" xmlns:m0="http://services.samples" type="string"/> </configuration> </rule> <send> <endpoint> <address uri="http://localhost:9000/services/SimpleStockQuoteService"/> </endpoint> </send> </in> <out> <send/> </out> </definitions>
<package name="SimpleMessageTransformationRules" xmlns="http://drools.org/drools-5.0" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:schemaLocation="http://drools.org/drools-5.0 drools-4.0.xsd"> <import name="org.apache.synapse.MessageContext"/> <import name="org.wso2.rule.Inputs"/> <import name="org.wso2.rule.Outputs"/> <rule name="Invoke Always IBM "> <lhs> <pattern object-type="MessageContext" identifier="mc"> </pattern> <pattern object-type="Inputs" identifier="inputs"> </pattern> <pattern object-type="Outputs" identifier="outputs"> </pattern> <eval>((String)inputs.get("symbol")).equals("MSFT") || ((String)inputs.get("symbol")).equals("SUN") </eval> </lhs> <rhs> outputs.put("symbol","IBM"); </rhs> </rule> </package>
Objective: Simple message transformation - Rule mediator for message transformation.
Prerequisites:
Start the Synapse configuration numbered 604: (i.e. ./wso2esb-samples.sh -sn 604)
Start the Axis2 server and deploy the SimpleStockQuoteService if not already deployed
In this sample , a simple transformation is happened . If the symbol is either SUN or MSFT , then it will changed into IBM in the SOAP envelope and then invoke the external service.
Run client as
ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/ -Dsymbol=MSFT
Or as
ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/ -Dsymbol=SUN
Then check the axis2server log or console .
Mon Mar 03 16:33:05 IST 2008 samples.services.SimpleStockQuoteService :: Generating quote for : IBM
<!-- Simple rule based transformation (changing message ) --> <definitions xmlns="http://ws.apache.org/ns/synapse"> <!-- the SimpleURLRegistry allows access to a URL based registry (e.g. file:/// or http://) --> <registry provider="org.wso2.carbon.mediation.registry.ESBRegistry"> <!-- the root property of the simple URL registry helps resolve a resource URL as root + key --> <parameter name="root">file:repository/samples/resources/</parameter> <!-- all resources loaded from the URL registry would be cached for this number of milli seconds --> <parameter name="cachableDuration">15000</parameter> </registry> <localEntry key="rule-script-key" src="file:repository/samples/resources/rule/commission_rule.xml"/> <in> <send> <endpoint> <address uri="http://localhost:9000/services/SimpleStockQuoteService"/> </endpoint> </send> </in> <out> <rule> <configuration xmlns="http://www.wso2.org/products/wso2commons/rule"> <ruleSource key="rule-script-key"/> <input name="symbol" type="string" expression="self::node()//m0:return/m1:symbol/child::text()" xmlns:m0="http://services.samples" xmlns:m1="http://services.samples/xsd"/> <input name="price" type="double" expression="self::node()//m0:return/m1:last/child::text()" xmlns:m0="http://services.samples" xmlns:m1="http://services.samples/xsd"/> <output name="price" type="double" expression="self::node()//m0:return/m1:last" xmlns:m0="http://services.samples" xmlns:m1="http://services.samples/xsd"/> </configuration> </rule> <send/> </out> </definitions>
<package name="SimpleMessageTransformationRules" xmlns="http://drools.org/drools-5.0" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:schemaLocation="http://drools.org/drools-5.0 drools-4.0.xsd"> <import name="org.apache.synapse.MessageContext"/> <import name="org.wso2.rule.Inputs"/> <import name="org.wso2.rule.Outputs"/> <import name="java.lang.Double"/> <rule name="Get commission form SUN and MSFT but not from IBM "> <lhs> <pattern object-type="MessageContext" identifier="mc"> </pattern> <pattern object-type="Inputs" identifier="inputs"> </pattern> <pattern object-type="Outputs" identifier="outputs"> </pattern> <eval>((String)inputs.get("symbol")).equals("MSFT") || ((String)inputs.get("symbol")).equals("SUN") </eval> </lhs> <rhs> Double price = (Double)inputs.get("price"); Object newPrice = price.doubleValue()+ 3000.68; outputs.put("price",newPrice); </rhs> </rule> </package>
Objective: Simple message transformation - Rule mediator for message transformation.
Prerequisites:
Start the Synapse configuration numbered 605: (i.e. ./wso2esb-samples.sh -sn
605)
Start the Axis2 server and deploy the SimpleStockQuoteService if not already
deployed.
This sample also illustrates a simple transformation using rule mediator. In here, for MSFT and SUN a commission is added to the price.(3000.68).
Invoke synapse(esb) with symbol IBM as
ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/
Then you will get the price as usual value .
Standard :: Stock price = $81.35674789750315
Then invoke synapse(esb) with symbol MSFT or SUN as
ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/ -Dsymbol=SUN
Then you will get the price whic is always above 3000.
Standard :: Stock price = $3082.1975970450094
<!-- Transformation with custom Java object --> <definitions xmlns="http://ws.apache.org/ns/synapse"> <!-- the SimpleURLRegistry allows access to a URL based registry (e.g. file:/// or http://) --> <registry provider="org.wso2.carbon.mediation.registry.ESBRegistry"> <!-- the root property of the simple URL registry helps resolve a resource URL as root + key --> <parameter name="root">file:repository/samples/resources/</parameter> <!-- all resources loaded from the URL registry would be cached for this number of milli seconds --> <parameter name="cachableDuration">15000</parameter> </registry> <localEntry key="rule-script-forward-key" src="file:repository/samples/resources/rule/tranform_forward_rule.drl"/> <localEntry key="rule-script-back-key" src="file:repository/samples/resources/rule/tranform_back_rule.drl"/> <in> <rule> <configuration xmlns="http://www.wso2.org/products/wso2commons/rule"> <ruleSource key="rule-script-forward-key" sourceFormat="drl"/> <ruleSet> <creation> <property name="source" value="drl"/> </creation> </ruleSet> <input name="symbol" expression="self::node()//m0:CheckPriceRequest/m0:Code/child::text()" xmlns:m0="http://services.samples" type="string"/> <output name="request" expression="self::node()//m0:CheckPriceRequest" xmlns:m0="http://services.samples" class="samples.GetQuoteRequest" type="custom"/> </configuration> <childMediators> <send> <endpoint> <address uri="http://localhost:9000/services/SimpleStockQuoteService"/> </endpoint> </send> <drop/> </childMediators> </rule> </in> <out> <rule> <configuration xmlns="http://www.wso2.org/products/wso2commons/rule"> <ruleSource key="rule-script-back-key" sourceFormat="drl"/> <ruleSet> <creation> <property name="source" value="drl"/> </creation> </ruleSet> <input name="symbol" type="string" expression="self::node()//m0:return/m1:symbol/child::text()" xmlns:m0="http://services.samples" xmlns:m1="http://services.samples/xsd"/> <input name="price" type="double" expression="self::node()//m0:return/m1:last/child::text()" xmlns:m0="http://services.samples" xmlns:m1="http://services.samples/xsd"/> <output name="response" type="custom" expression="self::node()//m0:return" class="samples.CheckPriceResponse" xmlns:m0="http://services.samples"/> </configuration> </rule> <send/> </out> </definitions>
<drl> <![CDATA[ package ForwardTransformation; import org.apache.synapse.MessageContext; import org.wso2.rule.Inputs; import org.wso2.rule.Outputs; import samples.GetQuoteRequest; rule ForwardTransformation when inputs : Inputs() outputs : Outputs() eval( (inputs.get("symbol") != null) ) then GetQuoteRequest request = new GetQuoteRequest(); request.setSymbol((String)inputs.get("symbol")); outputs.put("request",request); outputs.put("execute_children","true"); end ]]> </drl>
<drl> <![CDATA[ package BackwardTransformation; import org.apache.synapse.MessageContext; import org.wso2.rule.Inputs; import org.wso2.rule.Outputs; import samples.CheckPriceResponse; rule BackwardTransformation when inputs : Inputs() outputs : Outputs() eval( (inputs.get("price") != null) && (inputs.get("symbol") != null) ) then CheckPriceResponse response = new CheckPriceResponse(); response.setCode((String)inputs.get("symbol")); response.setPrice(((Double)inputs.get("price")).toString()); outputs.put("response",response); end ]]> </drl>
Objective: Advanced transformation using rule mediator.
Prerequisites:
Start the Synapse configuration numbered 606: (i.e. ./wso2esb-samples.sh -sn
606)
Start the Axis2 server and deploy the SimpleStockQuoteService if not already
deployed.
The classes GetQuoteRequest.java and CheckPriceResponse.java which are shown in bellow, have to be compiled and put in classpath. Easy way may be putting as a jar inside repository/components/lib. Pleas note that these classes need to be group to package samples.
This sample also illustrates a advanced transformation using rule mediator.
This sample illustrates the functionality offered by XSLT sample (sample 8 in the synapse (esb) samples). Both of the request and response are transformed.
In this sample , use CUTOM Java objects to archive the easy transformation. if the the toString() method returns a valid XML , it is possible to attached it into SOPA envelope. It is same concepts as serializing object into XML . In the sample used following Java Objects
For input transformation
package samples; /** * Represents the GetQuote Request - only for sample demonstration */ public class GetQuoteRequest { private String symbol; public String getSymbol() { return symbol; } public void setSymbol(String symbol) { this.symbol = symbol; } public String toXML() { return "<m:getQuote xmlns:m=\"http://services.samples\">" + "<m:request>" + "<m:symbol>" + symbol + "</m:symbol>" + "</m:request>" + "</m:getQuote>"; } }
For output transformation
package samples; /** * Represents the Check Price Response - only for sample demonstration */ public class CheckPriceResponse { private String code; private String price; public String getCode() { return code; } public void setCode(String code) { this.code = code; } public String getPrice() { return price; } public void setPrice(String price) { this.price = price; } public String toXML() { return "<m:CheckPriceResponse xmlns:m=\"http://services.samples\" " + "xmlns:m1=\"http://services.samples/xsd\">" + "<m1:Code>" + code + "</m1:Code>" + "<m1:Price>" + price + "</m1:Price>" + "</m:CheckPriceResponse>"; } }
This is just a example to show what kind of cool thing can be done using rule mediator.
Runs the client in custom mode as follows
ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/ -Dmode=customquote