mule - call subflow with in mule3 webservice -
i created mule3 simple front-end web service supposed pass xml message sub-flow , returns success caller.
mule-config.xml
<flow name="webservicetestflow"> <http:inbound-endpoint address="${webservicetest.env.endpoint}" exchange-pattern="request-response" doc:name="http"/> <cxf:simple-service serviceclass="com.test.webservicetest" doc:name="soap"/> <component class="com.test.webservicetestimpl" /> </flow>
sample webservice method
public class webservicetestimpl implements webservicetest,serializable { @override public string test(string requestmessage) throws exception{ // sends xml message sub-flow return "success"; }
the issue not find mule api call sub-flow in webservice method.
invoking sub-flow
code no small feat possible.
here test component invoke sub-flow
injected in it:
public class testcomponent implements mulecontextaware, flowconstructaware { private mulecontext mulecontext; private flowconstruct flowconstruct; private messageprocessor subflow; public void initialize() throws muleexception { mulecontext.getregistry().applyprocessorsandlifecycle(subflow); } public string test(final string requestmessage) throws exception { final muleevent muleevent = new defaultmuleevent(new defaultmulemessage(requestmessage, mulecontext), messageexchangepattern.request_response, flowconstruct); final muleevent resultevent = subflow.process(muleevent); return resultevent.getmessageasstring(); } public void setmulecontext(final mulecontext mulecontext) { this.mulecontext = mulecontext; } public void setflowconstruct(final flowconstruct flowconstruct) { this.flowconstruct = flowconstruct; } public void setsubflow(final messageprocessor subflow) { this.subflow = subflow; } }
the component configured way:
<spring:beans> <spring:bean name="testcomponent" class="com.example.testcomponent" p:subflow-ref="testsubflow" init-method="initialize" /> </spring:beans> ... <component> <spring-object bean="testcomponent" /> </component>
Comments
Post a Comment