Mule ESB: unable to copy message with thread payload

I have a Mule application in which I send a request to several web services and aggregate the list of answers that I receive, the idea is to get the first answer of the list by returning it from CustomJavaClass, where the list is processed:

return responses.get(0); 

I can achieve WSDL if I try to contact it through a browser, the returned WSDL looks as if it should look. But I'm trying to send a message through 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.p rocessor.MessageProcessors$LifecyleAwareMessageProcessorWrapper@ ceb6dd. Message payload is of type: ContentLengthInputStream 

my current configurations are:

 <?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> 
+6
source share
1 answer

Getting WSDL works because the GET request does not carry any payload. But when you try to call the SOAP method, the POST payload is an InputStream, which, of course, cannot be sent multiple times.

Thus: serialize the HTTP input stream with:

 <object-to-byte-array-transformer /> 

immediately after http: inbound-endpoint.

+8
source

Source: https://habr.com/ru/post/908743/


All Articles