0

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.

danw
  • 1,608
  • 4
  • 29
  • 48

1 Answers1

2

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

David Dossot
  • 33,403
  • 4
  • 38
  • 72
  • Is there a way I can check this? I'm new to working with HTTP endpoints. Working on a Mac if that makes a difference? The reason I used those credentials was because I followed [this](https://www.mulesoft.org/connectors/http-https-connector) tutorial from Mule on how to use an HTTP/HTTPS connector. – danw May 08 '14 at 14:02
  • Try: `curl http://localhost:8081/hello`. If you get a response, Mule should be able to get it too. – David Dossot May 08 '14 at 14:36
  • Thanks @David, it appears my Apache server was listening to port 80. I'm now having further issues with the response I'm getting in Mule (a variety of 400 errors)! Will post a new question if I can't get to the bottom of this. – danw May 08 '14 at 14:44