I have a Mule flow which uses HTTP Request endpoint in Mule CE3.6.1. It needs to use encoded HTTP url to get the correct data.
Please note the encoded url: /items?q=%2Blabel%3ABOTV2309H*%20%2Bparent.uri%3A%5C%2Fbristol%5C%2Ftest%5C%2Fgateway%5C%2F*&rows=100&start=0
Here is the test flow.
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans" version="CE-3.6.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8089" basePath="/" usePersistentConnections="false" doc:name="HTTP Listener Configuration"/>
<http:request-config name="HTTP_Request_Config_Search" host="testserver" port="80" basePath="/index" usePersistentConnections="false" doc:name="HTTP Request Configuration"/>
<flow name="testFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="*" allowedMethods="POST" doc:name="HTTP"/>
<object-to-string-transformer doc:name="Object to String"/>
<logger level="INFO" doc:name="Logger"/>
<http:request config-ref="HTTP_Request_Config_Search" path="/items?q=%2Blabel%3ABOTV2309H*%20%2Bparent.uri%3A%5C%2Fbristol%5C%2Ftest%5C%2Fgateway%5C%2F*&rows=100&start=0" method="GET" doc:name="HTTP"/>
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
</flow>
</mule>
When the Mule flow runs, here is the url being requested (Found through wireshark):
/items?q=%20label%3ABOTV2309H%2A%20%20parent.uri%3A%5C%2Fbristol%5C%2Ftest%5C%2Fgateway%5C%2F%2A&rows=100&start=0
Please note %2B is replaced with %20 in two places, which obviously do not return the data I need.
Is this an issue with HTTP endpoint?
Thanks!
I divided the params into query and uri params. Then this issue got resolved.
<http:request config-ref="HTTP_Request_Config_Search" path="/items" method="GET" doc:name="HTTP">
<http:request-builder>
<http:query-param paramName="q" value="+label:BOTV2309H* +parent.uri:\/test\/gateway\/*"/>
<http:uri-param paramName="rows" value="100"/>
<http:uri-param paramName="start" value="0"/>
</http:request-builder>
</http:request>
Related
I have one application which is Mule 3, now I need to migrate it into Mule 4.
I implemented and changed some code but it through exceptions that tag not supported i.e 'rest-router' is not supported.
<rest-router:router templateUri="${igate.url}">
<!--Migration ERROR: The migration of 'rest-router' is not supported.-->
<!-- For more information refer to:-->
<!-- * https://docs.mulesoft.com/mule-runtime/4.1/migration-connectors>--
<!-- * https://beta.docs.stgx.mulesoft.com/beta-mule-migration-tool/mule-runtime/4.1/migration-tool.html#unsupported_connectors-->
<rest-router:post>
<ee:transform xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" doc:name="JSON to Object">
<ee:message>
<ee:set-payload>%dw 2.0 output application/java --- payload as Object { class: 'com.ifi.igate.model.Transaction'}</ee:set-payload>
</ee:message>
</ee:transform>
<flow-ref name="igate-object-flow" doc:name="igate-object-flow" />
<ee:transform xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" doc:name="Object to JSON" mimeType="application/json">
<ee:message>
<ee:set-payload>%dw 2.0 output application/json --- payload</ee:set-payload>
</ee:message>
</ee:transform>
</rest-router:post>
</rest-router:router>
Full XML file in Mule 3 which we need to migrate on Mule 4 -
<spring:beans>
<spring:bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<spring:property name="ignoreUnresolvablePlaceholders" value="true"/>
<spring:property name="location" value="igate.properties"/>
</spring:bean>
<spring:bean id="validation" class="com.ifi.igate.integration.iclient.ValidationTransformer">
<spring:property name="transactionTypes">
<spring:list>
<spring:value>INQ-REQ</spring:value>
<spring:value>DEP-REQ</spring:value>
<spring:value>WIT-REQ</spring:value>
</spring:list>
</spring:property>
</spring:bean>
<spring:bean id="iGateStub" class="com.ifi.igate.stub.IGateStub">
<spring:property name="handlers">
<spring:map>
<spring:entry key="INQ-REQ">
<spring:bean class="com.ifi.igate.stub.handlers.InqHandler"/>
</spring:entry>
<spring:entry key="WIT-REQ">
<spring:bean class="com.ifi.igate.stub.handlers.WitHandler"/>
</spring:entry>
<spring:entry key="DEP-REQ">
<spring:bean class="com.ifi.igate.stub.handlers.DepHandler"/>
</spring:entry>
</spring:map>
</spring:property>
</spring:bean>
</spring:beans>
<rest-router:config/>
<http:connector name="httpConnector" doc:name="HTTP\HTTPS">
<receiver-threading-profile maxThreadsActive="10" />
</http:connector>
<flow name="igate-json-flow" doc:name="igate-json-flow">
<http:inbound-endpoint exchange-pattern="request-response" host="${igate.host}" port="${igate.port}" doc:name="HTTP"/>
<rest-router:router templateUri="${igate.url}">
<rest-router:post>
<json:json-to-object-transformer xmlns:json="http://www.mulesoft.org/schema/mule/json" returnClass="com.ifi.igate.model.Transaction" doc:name="JSON to Object"></json:json-to-object-transformer>
<flow-ref name="igate-object-flow" doc:name="igate-object-flow"/>
<json:object-to-json-transformer xmlns:json="http://www.mulesoft.org/schema/mule/json" doc:name="Object to JSON" mimeType="application/json"></json:object-to-json-transformer>
</rest-router:post>
</rest-router:router>
<rest-router:router templateUri="${igate-stub.url}">
<rest-router:post>
<json:json-to-object-transformer xmlns:json="http://www.mulesoft.org/schema/mule/json" returnClass="com.ifi.igate.model.Transaction" doc:name="JSON to Object"/>
<component doc:name="IGateStub">
<spring-object bean="iGateStub"/>
</component>
<json:object-to-json-transformer xmlns:json="http://www.mulesoft.org/schema/mule/json" doc:name="Object to JSON" mimeType="application/json"/>
</rest-router:post>
</rest-router:router>
</flow>
<sub-flow name="igate-object-flow" doc:name="igate-object-flow">
<transformer ref="validation"/>
<choice>
<when expression="#[message.payload.trxstatus == 0]">
<logger message="#[message.payload.trxreason]" level="ERROR" doc:name="Logger"/>
</when>
<otherwise>
<set-variable variableName="request" value="#[message.payload]" doc:name="save request"/>
<flow-ref name="promotions-flow" doc:name="Promotions Flow"/>
<flow-ref name="ifi-membership-flow" doc:name="Accumulate Spending"/>
<!-- logger message="Before backend" level="ERROR" doc:name="Logger"/-->
<flow-ref name="rewards-flow" doc:name="Rewards Flow"/>
<choice>
<when expression="#[message.payload.values['PTS']>0 || message.payload.trxtype=='INQ-REQ']">
<flow-ref name="${igate.membership}-membership-flow" doc:name="External Membership Flow"/>
</when>
<otherwise>
<vm:outbound-endpoint exchange-pattern="request-response" path="membership/ifi" />
</otherwise>
</choice>
<!-- logger message="After backend" level="ERROR" doc:name="Logger"/-->
<flow-ref name="promotions-flow" doc:name="Promotions Flow"/>
<flow-ref name="rewards-flow" doc:name="Rewards Flow"/>
<flow-ref name="ifi-membership-flow" doc:name="Manage balances"/>
<flow-ref name="pricing-flow" doc:name="Pricing Flow"/>
</otherwise>
</choice>
</sub-flow>
</mule>
'rest-router' is not supported in Mule 4 only need replacement for that tag or How I can migrate it into Mule 4.
rest-router seems to be an unsupported and unmaintained (last commit is from 2012) module for Mule 3. You best bet is to migrate from scratch and use APIKit instead. You will need to write a RAML specification for your API and Studio will create all the needed scaffolding from it.
I have the simple flows as following. When we hit one flow, it hits another flow and gets http.status 302 and Location , which means it must redirect to the location in Location header. But it is throwing exception.
<flow name="httpconnectorFlowRedirection">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="9876" path="redirect" connector-ref="NoSessionEncodingConnector" doc:name="HTTP"/>
<http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="9876" method="POST" doc:name="HTTP" path="temp" connector-ref="NoSessionEncodingConnector" contentType="text/plain"
followRedirects="true" />
<logger message="#[payload]" level="INFO" doc:name="Logger"/>
</flow>
<flow name="temp_flow">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="9876" path="temp" connector-ref="NoSessionEncodingConnector" doc:name="HTTP" />
<logger message="in temp flow" level="INFO" doc:name="Logger"/>
<set-property propertyName="http.status" value="307" doc:name="Property" />
<set-property propertyName="Location" value="http://localhost:9876/samplehttp" doc:name="Property" />
</flow>
Error I am getting is as follows
org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=http://localhost:9876/temp, connector=HttpConnector
{
name=NoSessionEncodingConnector
lifecycle=start
this=14c5f0c
numberOfConcurrentTransactedReceivers=4
createMultipleTransactedReceivers=true
connected=true
supportedProtocols=[http]
serviceOverrides=
session.handler=org.mule.session.NullSessionHandler
}
, name='endpoint.http.localhost.9876.temp', mep=REQUEST_RESPONSE, properties={exceptionOnMessageError=true, http.method=POST, followRedirects=true, Content-Type=text/plain}, transactionConfig=Transaction{factory=null, action=INDIFFERENT, timeout=0}, deleteUnacceptedMessages=false, initialState=started, responseTimeout=10000, endpointEncoding=UTF-8, disableTransportTransformer=false}. Message payload is of type: PostMethod
Type : org.mule.api.transport.DispatchException
Code : MULE_ERROR--2
JavaDoc : http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transport/Dispat chException.html
Payload : org.apache.commons.httpclient.methods.PostMethod#14efe2e
********************************************************************************
I am getting this error only when follow redirects set to true on outbound endpoint
I am using mule 3.5.
I got the answer. I need to use GET reqeust for successful redirection.
But if I use http listeners(since mule 3.6), I am able to redirect even for POST requests. Consider the following example.
<http:listener-config name="GlobalHTTPConnector" host="localhost" port="9876" doc:name="HTTP Listener Configuration" basePath="mulelearning"/>
<flow name="redirection-flow">
<http:listener config-ref="GlobalHTTPConnector" path="/requestredir" doc:name="HTTP"/>
<!--
When followRedirects is set to true, when http.status from called service is redirection(eg:301), it redirects to new location.
In this case /redFlow1 sends a redirection code 301 and location header. Hence it redirects to /redFlow2 (see the flows below) and gives us the response 'payload from red-flow2'
-->
<http:request config-ref="HTTP_Request_Configuration" path="/redFlow1" method="POST" followRedirects="true" doc:name="HTTP" />
</flow>
<flow name="red-ser1">
<http:listener config-ref="GlobalHTTPConnector" path="/redFlow1" doc:name="HTTP"/>
<logger level="INFO" doc:name="Logger" message="I am in red-flow1"/>
<set-payload value="payload from red-flow1" />
<set-property propertyName="http.status" value="301" doc:name="Property" />
<set-property propertyName="Location" value="http://localhost:9876/mulelearning/redFlow2" doc:name="Property" />
</flow>
<flow name="red-ser2">
<http:listener config-ref="GlobalHTTPConnector" path="/redFlow2" doc:name="HTTP"/>
<set-payload value="payload from red-flow2" />
<logger level="INFO" doc:name="Logger" message="I am in red-flow2"/>
</flow>
I'm new in Mule ESB and trying to send a post request to a REST Service. The body of the request is in String form and the request should be x-www-form-urlencoded. I set the payload to my parameters and send the request to the REST Service but I get an exception:
Failed to invoke REST service "http://username:password#192.168.10.252/api/rest/session/login.json". Message payload is of type: String
My Rest URL is: (#[restURL]) ${dms.host}/api/rest/session/login.json
My parameter is (set as payload #[restBody]): username=user&password=pass
<sub-flow name="RESTrequestToDMS" doc:name="RESTrequestToDMS" processingStrategy="synchronous">
<set-variable variableName="originalMessage" value="#[payload]" doc:name="Backup original message"/>
<logger message="#[restBody]" level="INFO" doc:name="Logger"/>
<choice doc:name="Choice">
<when expression="restHTTPmethod == 'POST'">
<processor-chain>
<set-payload value="#[restBody]" doc:name="Set Payload"/>
<http:rest-service-component httpMethod="POST" serviceUrl="http://${dms.user}:${dms.pass}##[restURL]"></http:rest-service-component>
</processor-chain>
</when>
<when expression="restHTTPmethod == 'GET'">
<processor-chain>
<http:rest-service-component httpMethod="GET" serviceUrl="http://${dms.user}:${dms.pass}##[restURL]?#[restBody]"></http:rest-service-component>
</processor-chain>
</when>
<otherwise>
<processor-chain>
<logger message="Unknown http method type is provided! " level="ERROR" doc:name="Logger"/>
</processor-chain>
</otherwise>
</choice>
<json:json-to-object-transformer returnClass="java.util.Map" doc:name="JSON to Object"/>
<echo-component doc:name="Echo"/>
<set-variable variableName="RESTResponse" value="#[payload]" doc:name="set RESTResponse"/>
<set-payload value="#[flowVars['originalMessage']]" doc:name="Restore Original Message"/>
</sub-flow>
Can somebody help me figure this out please?
Thanks a lot in advance.
Note: Updated according to David's reply.
-------------------UPDATE--------------------
So now, for testing purposes, I have modified the flow like this:
<set-payload value="#[restBody]" doc:name="Set Payload"/>
<custom-transformer class="de.mfg.osii.http.StringToURIParametersMapTransformer" doc:name="String To URI Parameters"/>
<http:rest-service-component httpMethod="POST" serviceUrl="http://${dms.user}:${dms.pass}##[restURL]">
<http:requiredParameter key="username" value="#[payload.get('username')]" />
<http:requiredParameter key="password" value="#[payload.get('password')]" />
</http:rest-service-component>
So now the payload is: {username=user, password=pass}
But now when I try to run this, I get the following error:
1. Failed to invoke REST service "http://user:pass#192.168.10.252/api/rest/session/login.json". Message payload is of type: LinkedHashMap (org.mule.transport.http.components.RestServiceException)
Update: The above problem, the exception, has just been solved by adding a message-property "Content-Type" with the value "application/x-www-form-urlencoded".
Still the last part, below, remains a mystery for me :)
The other thing is, as I stated in the comment to David's answer, can I add the required parameters for the rest component in an adaptive way? To be more clearer, I do not want to create different flows for every different request. I have the parameter map in the payload, so I want to iterate over them and put them in the required parameters. Is something like this possible?
Thanks a lot in advance!
-------------------UPDATE--------------------
So, I've modified my flow and used David's suggestions. However, now, I'm getting an HTTP 405 error (Method not allowed). But I'm sure I'm posting to the correct address with correct content-type. What is the reason for this? Does anybody have an idea?
My payload coming into this flow is a string (url encoded parameters) such as ->
sessionId=9eub9gm7k7oc1ub81dhef6t46q&xml=%3CObjectList%3E%3CFolderObject%3E%3CAddToFolder%20RefType%3D%22Path%22%20ClassName%3D%22FolderObject%22%3E%3C!%5BCDATA%5B%2FfolderPath%5D%5D%3E%3C%2FAddToFolder%3E%3CName%3E%3C!%5BCDATA%5Baaa%5D%5D%3E%3C%2FName%3E%3CDescription%3E%3C!%5BCDATA%5BRequests%20from%20user%20aaa%20are%20stored%20in%20this%20folder%5D%5D%3E%3C%2FDescription%3E%3CNoErrorIfExist%2F%3E%3C%2FFolderObject%3E%3C%2FObjectList%3E
<flow name="RESTrequestToDMS" doc:name="RESTrequestToDMS" processingStrategy="synchronous">
<set-variable variableName="originalMessage" value="#[payload]" doc:name="Backup original message"/>
<choice doc:name="Choice">
<when expression="restHTTPmethod == 'POST'">
<processor-chain>
<set-payload value="#[restBody]" doc:name="Set Payload"/>
<logger message="The payload before http post is: #[message.payload]" level="INFO" doc:name="Logger"/>
<http:outbound-endpoint exchange-pattern="request-response" doc:name="HTTP" address="http://#[restURL]" user="${dms.user}" password="${dms.pass}" contentType="application/x-www-form-urlencoded">
</http:outbound-endpoint>
</processor-chain>
</when>
<when expression="restHTTPmethod == 'GET'">
<processor-chain>
<http:outbound-endpoint method="GET" exchange-pattern="request-response" doc:name="HTTP" address="http://#[restURL]?#[restBody]" user="${dms.user}" password="${dms.pass}" contentType="application/x-www-form-urlencoded">
</http:outbound-endpoint>
</processor-chain>
</when>
<otherwise>
<processor-chain>
<logger message="Unknown http method type is provided! " level="ERROR" doc:name="Logger"/>
</processor-chain>
</otherwise>
</choice>
<echo-component doc:name="Echo"/>
<choice doc:name="Choice">
<when expression="payload != null && payload != empty && payload != ''">
<processor-chain>
<json:json-to-object-transformer doc:name="JSON to Object" returnClass="java.util.Map"/>
<set-variable variableName="RESTResponse" value="#[payload]" doc:name="set RESTResponse"/>
</processor-chain>
</when>
<otherwise>
<processor-chain>
<logger message="The payload is null or empty! HTTP response code is: #[message.inboundProperties['http.status']]" level="INFO" doc:name="Logger"/>
<set-variable variableName="RESTResponse" value="#[message.inboundProperties['http.status']]" doc:name="Set HTTP Status Code"/>
</processor-chain>
</otherwise>
</choice>
<set-payload value="#[flowVars['originalMessage']]" doc:name="Restore Original Message"/>
</flow>
Here is how you pass parameters to be URL encoded with the rest-service-component:
<http:rest-service-component httpMethod="POST"
serviceUrl="http://${dms.user}:${dms.pass}##[restURL]">
<http:requiredParameter key="username" value="user" />
<http:requiredParameter key="password" value="pass" />
</http:rest-service-component>
I want to select records from a database and use them across different flows in mule.
My approach is to get the records using a Spring bean and pass it to a hashmap then return the hashmap and save it in a session variable.
Currently getting this error:
Message : Execution of the expression "message.payload.getServiceCodes()" failed. (org.mule.api.expression.ExpressionRuntimeException). Message payload is of type: HashMap
Code : MULE_ERROR--2
Its there a better approach? Or what I'm I doing wrong?
My Configuration XML
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:quartz="http://www.mulesoft.org/schema/mule/quartz" xmlns:jdbc-ee="http://www.mulesoft.org/schema/mule/ee/jdbc" xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:data-mapper="http://www.mulesoft.org/schema/mule/ee/data-mapper" xmlns:xm="http://www.mulesoft.org/schema/mule/xml" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:jms="http://www.mulesoft.org/schema/mule/jms" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" version="EE-3.4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/ee/jdbc http://www.mulesoft.org/schema/mule/ee/jdbc/current/mule-jdbc-ee.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/data-mapper http://www.mulesoft.org/schema/mule/ee/data-mapper/current/mule-data-mapper.xsd
http://www.mulesoft.org/schema/mule/quartz http://www.mulesoft.org/schema/mule/quartz/current/mule-quartz.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">
<jms:activemq-connector name="Active_MQ" brokerURL="tcp://localhost:61616" validateConnections="true" doc:name="Active MQ"></jms:activemq-connector>
<xm:jaxb-context name="myJaxb" doc:name="myJaxb" packageNames="com.test.jaxb"></xm:jaxb-context>
<spring:beans>
<spring:bean id="springDataSource" name="Bean" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<spring:property name="url" value="jdbc:mysql://localhost:3306/muledb"></spring:property>
<spring:property name="maxActive" value="30"></spring:property>
<spring:property name="removeAbandoned" value="true"></spring:property>
<spring:property name="driverClassName" value="com.mysql.jdbc.Driver"></spring:property>
<spring:property name="initialSize" value="20"></spring:property>
<spring:property name="username" value="root"></spring:property>
</spring:bean>
</spring:beans>
<quartz:connector name="quartzConnector" doc:name="Quartz">
<quartz:factory-property key="org.quartz.scheduler.instanceName" value="MuleScheduler1"></quartz:factory-property>
<quartz:factory-property key="org.quartz.threadPool.class" value="org.quartz.simpl.SimpleThreadPool"></quartz:factory-property>
<quartz:factory-property key="org.quartz.threadPool.threadCount" value="3"></quartz:factory-property>
<quartz:factory-property key="org.quartz.scheduler.rmi.proxy" value="false"></quartz:factory-property>
<quartz:factory-property key="org.quartz.scheduler.rmi.export" value="false"></quartz:factory-property>
<quartz:factory-property key="org.quartz.jobStore.class" value="org.quartz.simpl.RAMJobStore"></quartz:factory-property>
</quartz:connector>
<jdbc-ee:mysql-data-source name="MySQL_Data_Source" user="root" password="" url="jdbc:mysql://localhost:3306/muledb" transactionIsolation="UNSPECIFIED" doc:name="MySQL Data Source"></jdbc-ee:mysql-data-source>
<jdbc-ee:connector name="Database" dataSource-ref="MySQL_Data_Source" validateConnections="true" transactionPerMessage="false" queryTimeout="-1" pollingFrequency="0" doc:name="Database"></jdbc-ee:connector>
<!-- <flow name="JMSMessageFlow1" doc:name="JMSMessageFlow1" >
<jdbc-ee:inbound-endpoint queryKey="FirstUpdate" queryTimeout="-1" connector-ref="Database" doc:name="Database" pollingFrequency="0">
<jdbc-ee:query key="FirstUpdate" value="SELECT * FROM gcp_txn_log WHERE PROCESSED= 'Y'"></jdbc-ee:query>
<jdbc-ee:query key="FirstUpdate.ack" value="update gcp_txn_log set PROCESSED='N' where service_id = #[map-payload:service_id]"></jdbc-ee:query>
</jdbc-ee:inbound-endpoint>
<logger level="INFO" doc:name="Logger"/>
</flow> -->
<!-- <flow name="JMSMessageFlow2" doc:name="JMSMessageFlow2">
<jdbc-ee:inbound-endpoint queryKey="SelectAll" queryTimeout="-1" connector-ref="Database" doc:name="Database" pollingFrequency="0">
<jdbc-ee:transaction action="ALWAYS_BEGIN"></jdbc-ee:transaction>
<jdbc-ee:query key="SelectAll" value="SELECT * FROM gcp_txn_log WHERE PROCESSED= 'N'"></jdbc-ee:query>
<jdbc-ee:query key="SelectAll.ack" value="update gcp_txn_log set PROCESSED='Y' where service_id = #[map-payload:service_id] "></jdbc-ee:query>
</jdbc-ee:inbound-endpoint>
<xm:object-to-xml-transformer doc:name="Object to XML"></xm:object-to-xml-transformer>
<file:outbound-endpoint path="C:\Users\FASYL\Downloads" outputPattern="test#[function:datestamp:dd-MM-yy]_#[function:systime].xml" responseTimeout="10000" doc:name="File"></file:outbound-endpoint>
<jdbc-ee:outbound-endpoint queryKey="FirstUpdate" queryTimeout="-1" connector-ref="Database" doc:name="Database">
<jdbc-ee:query key="FirstUpdate" value="update gcp_txn_log set PROCESSED = 'N' WHERE PROCESSED = 'Y'"></jdbc-ee:query>
</jdbc-ee:outbound-endpoint>
</flow> -->
<flow name="JMSMessageFlow3" doc:name="JMSMessageFlow3">
<quartz:inbound-endpoint jobName="job2" repeatInterval="1" repeatCount="0" responseTimeout="10000" doc:name="Quartz" connector-ref="quartzConnector">
<quartz:event-generator-job>
<quartz:payload>Setting Session Variable</quartz:payload>
</quartz:event-generator-job>
</quartz:inbound-endpoint>
<component class="com.test.SchedulerComponent" doc:name="Java"></component>
<component doc:name="Java">
<singleton-object class="com.test.ServiceDAO">
<property key="dataSource" value-ref="springDataSource" value="null"/>
</singleton-object>
</component>
<message-properties-transformer scope="session" doc:name="Message Properties">
<add-message-property key="serviceDAO" value="#[message.payload]"/>
</message-properties-transformer>
<logger level="INFO" doc:name="Logger" message="#[sessionVars['serviceDAO']['1001']]"/>
</flow>
<!-- <flow name="JMSMessageFlow1" doc:name="JMSMessageFlow1">
</flow> -->
<flow name="JMSMessageFlow4" doc:name="JMSMessageFlow4">
<jms:inbound-endpoint queue="StudioIns" connector-ref="Active_MQ" doc:name="JMS"/>
<xm:jaxb-xml-to-object-transformer jaxbContext-ref="myJaxb" returnClass="com.test.jaxb.MsgContent"></xm:jaxb-xml-to-object-transformer>
<choice doc:name="Choice">
<when expression="payload.getMsgBody().getValue() == 'fundstransfer'" >
<pooled-component doc:name="Java">
<prototype-object class="com.test.PersonComponent">
<property key="dataSource" value-ref="springDataSource" value="null"/>
</prototype-object>
</pooled-component>
</when>
<when expression="#[sessionVars['serviceDAO']['1001'] == 1] ">
<pooled-component doc:name="Java">
<prototype-object class="com.test.SecondPersonComponent">
<property key="dataSource" value-ref="springDataSource" value="null"/>
</prototype-object>
</pooled-component>
</when>
</choice>
<logger message="#[sessionVars['serviceDAO']]" level="INFO" doc:name="Logger"/>
<file:outbound-endpoint path="D:\Documents\MuleStudio\workspace\jms_amq\bin\com\test" outputPattern="new.txt" responseTimeout="10000" doc:name="File"/>
</flow>
</mule>
The error indicates your payload is a HashMap: "Message payload is of type: HashMap". So the expression: message.payload.getServiceCodes() won't work as a HashMap doesn't have a method named 'getServiceCodes()'. If you want access elements of that HashMap you can use MEL(Mule Expression Language - http://www.mulesoft.org/documentation/display/current/Mule+Expression+Language+MEL) in a few ways.
Either via standard java method invocation such as:
payload.get('mykey')
or you can use MEL short hand such as:
payload['mykey'] or payload.mykey
Ont he other point about session variables you can store it in a session variable via the "set-session-variable" message processor and access the elements in a similar way. You can refer to it using "sessionVars" instead of "payload" and this time it will be a map of maps so:
sessionVars.mymap.mykey or sessionVars['mymap']['mykey'] etc.
When I run my flow, I get the following error `
<org.apache.cxf.staxutils.DepthXMLStreamReader>
<reader class="org.mule.module.cxf.support.StreamClosingInterceptor$1">
<reader class="com.ctc.wstx.sr.ValidatingStreamReader">
<mXml11>false</mXml11>
<mInputBuffer>xmlns:ns2="http://wsdouane/"><return><douanePK><idConteneurId>ctr1</idConteneurId><idCritereId>C11</idCritereId></douanePK><valeurId>oui</valeurId></return></ns2:findResponse></S:Body></S:Envelope>.................
we can see the correct soap response starting from the <mInputBuffer>, is there a way to get only the soap response??
here is my flow
<flow name="SOAPWebService" doc:name="SOAPWebService">
<http:inbound-endpoint exchange-pattern="request-response" address="http://localhost:8088/esb" doc:name="HTTP"/>
<object-to-string-transformer doc:name="Object to String"/>
<choice doc:name="Choice">
<when expression="#[payload.contains('C22')]">
<set-variable variableName="paramCtr" value="#[message.inboundProperties['ctr']]" doc:name="conteneur"/>
<set-variable variableName="paramC" value="#[message.inboundProperties['c']]" doc:name="critere"/>
<component class="com.example.components.SampleComponent" doc:name="Java"/>
<mulexml:xslt-transformer maxIdleTransformers="2" maxActiveTransformers="5" xsl-file="C:\MuleStudio\SandBox\resources\PrepareRequestXMLPort.xsl" doc:name="XSLT">
<mulexml:context-property key="paramCtr" value="#[flowVars['paramCtr']]" />
<mulexml:context-property key="paramC" value="#[flowVars['paramC']]" />
</mulexml:xslt-transformer>
<cxf:proxy-client payload="body" enableMuleSoapHeaders="true" doc:name="SOAP"/>
<http:outbound-endpoint exchange-pattern="request-response" address="http://localhost:8080/ClientsDB/port" doc:name="PortWS"/>
<byte-array-to-string-transformer doc:name="Byte Array to String" />
</when>
<otherwise>
<set-variable variableName="paramCtr" value="#[message.inboundProperties['ctr']]" doc:name="conteneur"/>
<set-variable variableName="paramC" value="#[message.inboundProperties['c']]" doc:name="critere"/>
<component class="com.example.components.SampleComponent" doc:name="Java"/>
<mulexml:xslt-transformer maxIdleTransformers="2" maxActiveTransformers="5" xsl-file="C:\MuleStudio\SandBox\resources\PrepareRequestXMLDouane.xsl" doc:name="XSLT">
<mulexml:context-property key="paramCtr" value="#[flowVars['paramCtr']]" />
<mulexml:context-property key="paramC" value="#[flowVars['paramC']]" />
</mulexml:xslt-transformer>
<cxf:proxy-client payload="body" enableMuleSoapHeaders="true" doc:name="SOAP"/>
<http:outbound-endpoint exchange-pattern="request-response" address="http://localhost:8080/ClientsDB/douane" doc:name="DouaneWS"/>
<byte-array-to-string-transformer doc:name="Byte Array to String"/>
</otherwise>
</choice>
<xm:object-to-xml-transformer doc:name="Object to XML"/>
<file:outbound-endpoint path="C:\MuleStudio\SandBox\output" outputPattern="#[function:datestamp:dd-MM-yy]_#[function:systime].xml " responseTimeout="10000" doc:name="Outgoing File"/>
</flow>
thank you.
This expression #[payload.contains('c22')] can't work because the payload is an InputStream. Aren't you seeing stack traces in Mule's logs?
In any case, try adding <object-to-string-transformer /> before the choice and see if it fixes the issue.
EDIT:
The problem is that you're using XStream (in xm:object-to-xml-transformer) to serialize the CXF response object (org.apache.cxf.staxutils.DepthXMLStreamReader) into XML. The CXF response should not be messed with and should be handled by the cxf:proxy-client in the response phase of the flow. The xm:object-to-xml-transformer and file:outbound-endpoint after the choice router are probably disturbing this mechanism. Try to wrap them in a response element above the choice router to they execute after it in the response phase.
Note that I have already given you this advice in your other question https://stackoverflow.com/a/16615537/387927 but you did not react to it.
Also I don't think byte-array-to-string-transformer does anything: the message payload after the http:outbound-endpoints should be org.apache.cxf.staxutils.DepthXMLStreamReader, preventing this transformer to fire.