Mule ESB: All Routing Message Processor has a weird output - esb

I have an All Routing Message Processor where I send a request from a Client to multiple External services , I can send the request and I get the response but the response looks a bit weird:
<java.util.concurrent.CopyOnWriteArrayList serialization="custom">
<java.util.concurrent.CopyOnWriteArrayList>
<default/>
<int>2</int>
<byte-array>PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48IS0tIFB1Ymxpc2hlZCBieSBK
QVgtV1MgUkkgYXQgaHR0cDovL2pheC13cy5kZXYuamF2YS5uZXQuIFJJJ3MgdmVyc2lvbiBpcyBK
QVgtV1MgUkkgMi4xLjYuIC0tPjwhLS0gR2VuZXJhdGVkIGJ5IEpBWC1XUyBSSSBhdCBodHRwOi8v
amF4LXdzLmRldi5qYXZhLm5ldC4gUkkncyB2ZXJzaW9uIGlzIEpBWC1XUyBSSSAyLjEuNi4gLS0+
PGRlZmluaXRpb25zIHhtbG5zOnNvYXA9Imh0dHA6Ly9zY2hlbWFzLnhtbHNvYXAub3JnL3dzZGwv
c29hcC8iIHhtbG5zOnRucz0iaHR0cDovL21pbml3ZWJzZXJ2aWNlLyIgeG1sbnM6eHNkPSJodHRw
Oi8vd3d3LnczLm9yZy8yMDAxL1hNTFNjaGVtYSIgeG1sbnM9Imh0dHA6Ly9zY2hlbWFzLnhtbHNv
YXAub3JnL3dzZGwvIiB0YXJnZXROYW1lc3BhY2U9Imh0dHA6Ly9taW5pd2Vic2VydmljZS8iIG5h
bWU9IkhhbGxvV2VsdEltcGxTZXJ2aWNlIj4KPHR5cGVzPgo8eHNkOnNjaGVtYT4KPHhzZDppbXBv
cnQgbmFtZXNwYWNlPSJodHRwOi8vbWluaXdlYnNlcnZpY2UvIiBzY2hlbWFMb2NhdGlvbj0iaHR0
cDovL2xvY2FsaG9zdDo0NDM1L21pbml3ZWJzZXJ2aWNlL21pbml3ZWJzZXJ2aWNlP3hzZD0xIi8+
CjwveHNkOnNjaGVtYT4KPC90eXBlcz4KPG1lc3NhZ2UgbmFtZT0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bWluaXdlYnNlcnZpY2UvbWluaXdlYnNlcnZpY2UiLz4KPC9wb3J0
GlvbnM+</byte-array> Pgo8L3NlcnZpY2U+CjwvZGVmaW5pdGlvbnM+</byte-array>
</java.util.concurrent.CopyOnWriteArrayList>
</java.util.concurrent.CopyOnWriteArrayList>
Any suggestion how to solve this?
Update :
Here is my current configuration :
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core" xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf" xmlns:tcp="http://www.mulesoft.org/schema/mule/tcp" xmlns:jms="http://www.mulesoft.org/schema/mule/jms" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="CE-3.2.1" xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd
http://www.mulesoft.org/schema/mule/tcp http://www.mulesoft.org/schema/mule/tcp/current/mule-tcp.xsd
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd ">
<flow name="flows1Flow1" doc:name="flows1Flow1">
<http:inbound-endpoint exchange-pattern="request-response" address="http://localhost:4433/miniwebservice" mimeType="text/xml" doc:name="HTTP"/>
<logger level="INFO" category="ddo" doc:name="Logger"/>
<all doc:name="All">
<processor-chain>
<message-properties-transformer mimeType="text/xml" doc:name="Message Properties">
<add-message-property key="http.method" value="#[header:INBOUND:http.method]"/>
</message-properties-transformer>
<http:outbound-endpoint exchange-pattern="request-response" address="http://localhost:4435/miniwebservice#[header:INBOUND:http.request]" mimeType="text/xml" doc:name="HTTP"/>
<mulexml:xslt-transformer maxIdleTransformers="2" maxActiveTransformers="5" xsl-file="C:\Users\kiesa\Desktop\XSLReplace.xsl" doc:name="XSLT"/>
</processor-chain>
<processor-chain>
<message-properties-transformer mimeType="text/xml" doc:name="Message Properties">
<add-message-property key="http.method" value="#[header:INBOUND:http.method]"/>
</message-properties-transformer>
<http:outbound-endpoint exchange-pattern="request-response" address="http://localhost:4434/miniwebservice#[header:INBOUND:http.request]" mimeType="text/xml" doc:name="HTTP"/>
<mulexml:xslt-transformer maxIdleTransformers="2" maxActiveTransformers="5" xsl-file="C:\Users\kiesa\Desktop\XSLReplace2.xsl" doc:name="XSLT"/>
</processor-chain>
</all>
<custom-aggregator failOnTimeout="true" class="customJavaClass" doc:name="Custom Aggregator"/>
<mulexml:object-to-xml-transformer doc:name="Object to XML"/>
</flow>
</mule>

There is nothing to solve here: the result of an All Routing Message Processor is a java.util.List of payloads received from each call to each message processor inside the All one.
You must have an object-to-xml transformation configured somewhere: this is why the List payload is turned into XML by using an XStream-powered serialization.
You need to deal with this list, for example with a custom component that can process a java.util.List payload.

Related

Get files from S3 bucket sub folders and process the files in Mule

I have the following folder structure in a S3 bucket called "test-files":
pending-files/products
pending-files/prices
Each folder contains a number of small CSV files and I want to retrieve them all in one call and then process each file in a For Each loop which contains a Choice component to redirect the payload based on the folder name e.g. "products" or "price".
I use List Objects to retrieve the files and have been able to retrieve all the files but the list contains an entry for the folder and the For Each will fail validation due to the folder not being a valid CSV file and also will fail the empty file check because the size will be 0.
How can I do this?
XML Workflow:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns:file="http://www.mulesoft.org/schema/mule/file"
xmlns:s3="http://www.mulesoft.org/schema/mule/s3" 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"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
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/s3 http://www.mulesoft.org/schema/mule/s3/current/mule-s3.xsd
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">
<flow name="listobjects">
<poll doc:name="Poll">
<fixed-frequency-scheduler frequency="1000" timeUnit="HOURS"/>
<s3:list-objects config-ref="Amazon_S3__Configuration" bucketName="test-files" prefix="pending-files/" maxKeys="5" doc:name="Amazon S3" delimiter="/" marker="pending-files/"/>
</poll>
<foreach collection="#[payload.objectSummaries]" doc:name="For Each">
<logger message="#[payload.getKey()]" level="INFO" doc:name="Logger"/>
<s3:get-object-content config-ref="Amazon_S3__Configuration" bucketName="test-file-drop" key="#[payload.getKey()]" mimeType="application/csv" doc:name="Amazon S3"/>
<choice doc:name="Choice">
<when expression="">
<flow-ref name="csvToMongodbFlow" doc:name="csvToMongodbFlow"/>
</when>
<otherwise>
<logger message="#['*************Missed*****************']" level="INFO" doc:name="Logger"/>
</otherwise>
</choice>
</foreach>
<logger message="#['\nCompleted']" level="INFO" doc:name="Logger"/>
</flow>
</mule>

insert into database with anypoint studio

I would like to save the flow coming from this json file: https://gist.githubusercontent.com/Rajeun/3dbbe8ca240d479dbabe/raw/aba5d0ec9345b886426ab767376b7c9cb60c251f/person.json in a database using anypoint studio.
For this i'm using a http connector where i mentioned the link of the json file. and then i used a json-to-object transformer and a database connector.
In my db i have a table with id, token, tel "int" and email is a varchar
-(I tested the connection and its working well).
when i run my code:
ERROR 2015-03-20 13:14:05,522 [main] org.mule.module.launcher.application.DefaultMuleApplication: null
java.lang.NullPointerException
at org.mule.module.db.internal.config.domain.query.QueryTemplateBeanDefinitionParser.parseParameterizedQuery(QueryTemplateBeanDefinitionParser.java:136) ~[mule-module-db-3.6.1.jar:3.6.1]
at org.mule.module.db.internal.config.domain.query.QueryTemplateBeanDefinitionParser.doParse(QueryTemplateBeanDefinitionParser.java:62) ~[mule-module-db-3.6.1.jar:3.6.1]
at org.mule.config.spring.parsers.AbstractMuleBeanDefinitionParser.parseInternal(AbstractMuleBeanDefinitionParser.java:295) ~[mule-module-spring-config-3.6.1.jar:3.6.1]
at org.springframework.beans.factory.xml.AbstractBeanDefinitionParser.parse(AbstractBeanDefinitionParser.java:59) ~[spring-beans-3.2.10.RELEASE.jar:3.2.10.RELEASE]
at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:73) ~[spring-beans-3.2.10.RELEASE.jar:3.2.10.RELEASE]
at org.mule.config.spring.MuleHierarchicalBeanDefinitionParserDelegate.parseCustomElement(MuleHierarchicalBeanDefinitionParserDelegate.java:98) ~[mule-module-spring-config-3.6.1.jar:3.6.1]
at org.mule.config.spring.MuleHierarchicalBeanDefinitionParserDelegate.parseCustomElement(MuleHierarchicalBeanDefinitionParserDelegate.java:140) ~[mule-module-spring-config-3.6.1.jar:3.6.1]
******************************************************************************
Config:
<mule xmlns:db="http://www.mulesoft.org/schema/mule/db" xmlns:json="http://www.mulesoft.org/schema/mule/json" 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="EE-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://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd">
<http:listener-config name="HTTP_Listener_Configuration" host="www.gist.githubusercontent.com" port="80" doc:name="HTTP Listener Configuration"/>
<db:mysql-config name="MySQL_Configuration" host="localhost" port="3306" user="root" database="mulesoft" doc:name="MySQL Configuration"/>
<db:template-query name="Template_Query" doc:name="Template Query">
<db:parameterized-query/>
</db:template-query>
<flow name="testFlow">
<http:listener config-ref="HTTP_Listener_Configuration" path="Rajeun/3dbbe8ca240d479dbabe/raw/aba5d0ec9345b886426ab767376b7c9cb60c251f/person.json" doc:name="HTTP"/>
<json:json-to-object-transformer returnClass="myclass" doc:name="JSON to Object"/>
<response>
<logger message="c bon" level="INFO" doc:name="Logger"/>
</response>
<response>
<db:insert config-ref="MySQL_Configuration" doc:name="Database">
<db:parameterized-query><![CDATA[INSERT INTO push(id, token, tel, email) VALUES (2,2,3,#[payload['userImage']])]]></db:parameterized-query>
</db:insert>
</response>
</flow>
</mule>
Remove the empty template query:
<db:template-query name="Template_Query" doc:name="Template Query">
<db:parameterized-query />
</db:template-query>
Also, does 'myclass' exist? if not try just using a map:
<json:json-to-object-transformer returnClass="java.util.HashMap" doc:name="JSON to Object"/>
Also It looks like you want to retrieve that JSON file from the specified URL. For that you want the http:request not http:listener. http:listener is used as a message source waiting for requests to your app.
You should use the http:request to request the file and trigger it using a polling message source:
<http:request-config name="HTTP_Request_Configuration" host="www.gist.githubusercontent.com" port="80" doc:name="HTTP Request Configuration"/>
<flow name="testFlow">
<poll>
<http:request config-ref="HTTP_Request_Configuration" path="Rajeun/3dbbe8ca240d479dbabe/raw/aba5d0ec9345b886426ab767376b7c9cb60c251f/person.json" method="GET" doc:name="HTTP"/>
</poll>
</flow>
See: http://www.mulesoft.org/documentation/display/current/HTTP+Request+Connector
And: http://www.mulesoft.org/documentation/display/current/Poll+Reference

Mule ESB, returning the Database Connector data in a JSON like format

I have a simple flow, that receives a REST, but without any corresponding data being input to the flow
The following is the XML:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:db="http://www.mulesoft.org/schema/mule/db" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" 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="EE-3.5.0"
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/db http://www.mulesoft.org/schema/mule/db/current/mule-db.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/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">
<db:generic-config name="Generic_Database_Configuration" url="jdbc:db2://localhost:50000/TEST:user=instuid;password=instpw;" driverClassName="com.ibm.db2.jcc.DB2Driver" doc:name="Generic Database Configuration"/>
<flow name="test2Flow1" doc:name="test2Flow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP"/>
<db:select config-ref="Generic_Database_Configuration" doc:name="Database" doc:description="test">
<db:parameterized-query><![CDATA[SELECT ACCTNUM FROM xxx.ACCOUNT]]></db:parameterized-query>
</db:select>
</flow>
</mule>
The SQL from the command line (outside of Mule) returns the following:
db2 => SELECT ACCTNUM FROM xxx.ACCOUNT
ACCTNUM
----------
11111
22222
The flow then executes a fully configured Database Connector, The data ten is passed to the outbound http connector:
C:\curl>curl http://localhost:8081
¼φ ♣sr ¶java.util.LinkedList♀)S]J`ê"♥ xpw♦ ☻sr $org.mule.util.CaseInsensitive
HashMap¥╤┘∩gE╬ ♥ xpw♀?# ► ☺t ACCTNUMt
11111 xsq ~ ☻w♀?# ► ☺q ~ ♦t
22222 xx
...so you can see that it is getting the variables from the table '11111' and '22222'.
What I don't know yet is what to do now. I want to take the result of the Database Connector, and return the strings '11111' and '22222'. in a JSON like format, but I do not know how to do that
Could someone please tell me the exasiest way to do that, and perhaps provide an example?
Thanks
Yes you are going right .... Just put a Object to JSON Transformer after the DB connector at the end like <json:object-to-json-transformer doc:name="Object to JSON"/> ... see the following :-
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:db="http://www.mulesoft.org/schema/mule/db" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" 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="EE-3.5.0"
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/db http://www.mulesoft.org/schema/mule/db/current/mule-db.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/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">
<db:generic-config name="Generic_Database_Configuration" url="jdbc:db2://localhost:50000/TEST:user=instuid;password=instpw;" driverClassName="com.ibm.db2.jcc.DB2Driver" doc:name="Generic Database Configuration"/>
<flow name="test2Flow1" doc:name="test2Flow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP"/>
<db:select config-ref="Generic_Database_Configuration" doc:name="Database" doc:description="test">
<db:parameterized-query><![CDATA[SELECT ACCTNUM FROM xxx.ACCOUNT]]></db:parameterized-query>
</db:select>
<json:object-to-json-transformer doc:name="Object to JSON"/>
</flow>
</mule>

How to returned with custmise response to client using Mule ESB

I am new for the mule esb but i know other ESB patterns
my issue is i have done a sample which will insert a data into DB.its working fine but its not giving any response to client so client is getting nothing from server
my sample code is
<mule xmlns:json="http://www.mulesoft.org/schema/mule/json"
xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:jdbc-ee="http://www.mulesoft.org/schema/mule/ee/jdbc"
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.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
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/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">
<jdbc-ee:postgresql-data-source name="PostgreSQL_Data_Source" user="youtilitydba" password="45782dfff1" url="jdbc:postgresql://localhost:5432/sample" transactionIsolation="UNSPECIFIED" doc:name="PostgreSQL Data Source"/>
<jdbc-ee:connector name="Database" dataSource-ref="PostgreSQL_Data_Source" validateConnections="true" queryTimeout="-1" pollingFrequency="0" doc:name="Database"/>
<flow name="insertintoDBFlow1" doc:name="insertintoDBFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP" path="httpPost"/>
<logger message="log about input message: #[payload]" level="INFO" doc:name="Logger"/>
<json:json-to-object-transformer doc:name="JSON to Object" returnClass="java.util.Map"></json:json-to-object-transformer>
<jdbc-ee:outbound-endpoint exchange-pattern="one-way" queryKey="INSERT_TOKEN" queryTimeout="-1" connector-ref="Database" doc:name="Database">
<jdbc-ee:query key="INSERT_TOKEN" value="insert into users(FirstName,lastname) values(#[message.payload.name],#[message.payload.id]);"/>
</jdbc-ee:outbound-endpoint>
</flow>
</mule>
and i am calling to this using sample JSON client like this
curl -H "Content-Type: application/json" -d '{"name":"kk","id":"anil"}' http://localhost:8081/httpPost
when i am running this json its giving nothing response but i wish to give response like this {"ResponseJSON":{"Body":{"Datalist":{"Data":"Successfully Rows inserted"}},"Status":"200"}}
how would i format this above format i used http response builder but there is nothing to do like this..
you need to add an Echo component, set the payload to the value you are looking for and add a HTTP Response Builder with status="200" and contentType="application/json".
Add the following lines after </jdbc-ee:outbound-endpoint> and before </flow>
<response>
<http:response-builder status="200" contentType="application/json" doc:name="HTTP Response Builder"/>
</response>
<response>
<set-payload value="{"Body":{"Datalist":{"Data":"Successfully Rows inserted"}},"Status":"200"}}" doc:name="Set Payload"/>
</response>
<echo-component doc:name="Echo"/>
Cheers,
-Marco.

Mule ESB : Cannot copy message with a stream payload

I have a Mule Application where I send a Request to Multiple WebServices and aggregate the List of responses i get , the idea is to get the first response of the List by returning it from the CustomJavaClass where the list is handled :
return responses.get(0);
I am able to reach the WSDL if I try to reach it over a Browser , the returned WSDL looks like its supposed to look . But i I try to send a message via SoapUi i get the following exception :
Exception stack is:
1. Cannot copy message with a stream payload. Payload type is "org.apache.commons.httpclient.ContentLengthInputStream". Message payload is of type: ContentLengthInputStream (org.mule.api.MessagingException)
org.mule.routing.outbound.AbstractSequenceRouter:73 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
org.mule.api.MessagingException: Cannot copy message with a stream payload. Payload type is "org.apache.commons.httpclient.ContentLengthInputStream". Message payload is of type: ContentLengthInputStream
at org.mule.routing.outbound.AbstractSequenceRouter.route(AbstractSequenceRouter.java:73)
at org.mule.routing.outbound.AbstractOutboundRouter$1.doInTransaction(AbstractOutboundRouter.java:102)
at org.mule.routing.outbound.AbstractOutboundRouter$1.doInTransaction(AbstractOutboundRouter.java:99)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
SOAPUi Exception :
Failed to route event via endpoint: org.mule.api.processor.MessageProcessors$LifecyleAwareMessageProcessorWrapper#ceb6dd. Message payload is of type: ContentLengthInputStream
my current configurations :
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core" xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf" xmlns:tcp="http://www.mulesoft.org/schema/mule/tcp" xmlns:jms="http://www.mulesoft.org/schema/mule/jms" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="CE-3.2.1" xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd
http://www.mulesoft.org/schema/mule/tcp http://www.mulesoft.org/schema/mule/tcp/current/mule-tcp.xsd
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd ">
<flow name="flows1Flow1" doc:name="flows1Flow1">
<http:inbound-endpoint exchange-pattern="request-response" address="http://localhost:4433/miniwebservice" encoding="UTF-8" mimeType="text/xml" doc:name="HTTP"/>
<logger level="INFO" category="ddo" doc:name="Logger"/>
<all doc:name="All">
<processor-chain>
<message-properties-transformer encoding="UTF-8" mimeType="text/xml" doc:name="Message Properties">
<add-message-property key="http.method" value="#[header:INBOUND:http.method]"/>
</message-properties-transformer>
<http:outbound-endpoint exchange-pattern="request-response" address="http://localhost:4435/miniwebservice#[header:INBOUND:http.request]" encoding="UTF-8" mimeType="text/xml" doc:name="HTTP"/>
<mulexml:xslt-transformer mimeType="text/xml" maxIdleTransformers="2" maxActiveTransformers="5" xsl-file="C:\Users\kiesa\Desktop\XSLReplace.xsl" doc:name="XSLT"/>
</processor-chain>
<processor-chain>
<message-properties-transformer encoding="UTF-8" mimeType="text/xml" doc:name="Message Properties">
<add-message-property key="http.method" value="#[header:INBOUND:http.method]"/>
</message-properties-transformer>
<http:outbound-endpoint exchange-pattern="request-response" address="http://localhost:4434/miniwebservice#[header:INBOUND:http.request]" encoding="UTF-8" mimeType="text/xml" doc:name="HTTP"/>
<mulexml:xslt-transformer mimeType="text/xml" maxIdleTransformers="2" maxActiveTransformers="5" xsl-file="C:\Users\kiesa\Desktop\XSLReplace2.xsl" doc:name="XSLT"/>
</processor-chain>
</all>
<mulexml:xml-to-object-transformer doc:name="XML to Object"/>
<component class="CustomJavaClass" doc:name="Java"/>
<byte-array-to-string-transformer ignoreBadInput="true" encoding="UTF-8" mimeType="text/xml" doc:name="Byte Array to String"/>
</flow>
</mule>
Getting the WSDL works because the GET request carries no payload. But when you try to invoke a SOAP method, the POST payload is an InputStream, which of course can't be dispatched several times.
Thus: serialize the HTTP input stream with a:
<object-to-byte-array-transformer />
right after the http:inbound-endpoint.