Question

I have a Mule flow that is converting an inbound file into some XML and I wish to post this to an HTTP outbound endpoint but my flow fails when I attempt to do so. My flow looks as follows:

<flow name="mainFlow" processingStrategy="synchronous">
   <file:inbound-endpoint name="fileIn" path="path/to/file"/>

   <file:file-to-string-transformer />

   <component class="CUSTOM JAVA CLASS TO CONVERT CSV INPUT TO BASIC XML"/>

   <mulexml:xml-to-dom-transformer returnClass="org.w3c.dom.Document"/>

   <!-- XSLT converts my Java-produced XML to a more complex structure for output -->
   <mulexml:xslt-transformer maxIdleTransformers="2" maxActiveTransformers="5" xsl-file="path/to/xsl"/>

   <object-to-string-transformer doc:name="Object to String"/>

   <!-- AT THIS POINT, THE PAYLOAD IS A STRING OF XML (payload=java.lang.String) -->

   <http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="hello" contentType="text/xml" method="POST" doc:name="HTTP"/>
</flow>

The errors I'm getting are as follows:

ERROR 2014-05-08 10:39:41,449 [[processes].consignmentInputFileConnector.receiver.02] org.mule.exception.CatchMessagingExceptionStrategy: 
********************************************************************************
Message               : Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=http://localhost:8081/hello, connector=HttpConnector
{
  name=connector.http.mule.default
  lifecycle=start
  this=45f8d5e5
  numberOfConcurrentTransactedReceivers=4
  createMultipleTransactedReceivers=true
  connected=true
  supportedProtocols=[http]
  serviceOverrides=<none>
}
,  name='endpoint.http.localhost.8081.hello', mep=REQUEST_RESPONSE, properties={http.method=POST, Content-Type=text/xml}, 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
Code                  : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. Connection refused (java.net.ConnectException)
  java.net.PlainSocketImpl:-2 (null)
2. Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=http://localhost:8081/hello, connector=HttpConnector
{
  name=connector.http.mule.default
  lifecycle=start
  this=45f8d5e5
  numberOfConcurrentTransactedReceivers=4
  createMultipleTransactedReceivers=true
  connected=true
  supportedProtocols=[http]
  serviceOverrides=<none>
}
,  name='endpoint.http.localhost.8081.hello', mep=REQUEST_RESPONSE, properties={http.method=POST, Content-Type=text/xml}, 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 (org.mule.api.transport.DispatchException)
  org.mule.transport.http.HttpClientMessageDispatcher:155 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transport/DispatchException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.net.ConnectException: Connection refused
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)
    + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************

The end goal of what I'm trying to achieve here is to evaluate the response code received from the HTTP endpoint and then proceed accordingly. However, I've so far been unable to get as far as posting successfully.

Was it helpful?

Solution

Are you sure something is listening on http://localhost:8081/hello? The java.net.ConnectException tends to say the opposite.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top