I need to transfer XML-files over HTTP POST. Can Mule be configured to do this. I've been trying with an easy flow, inbound file --> outound HTTP but it's not working. Does anyone have any experience of this?
<flow name="rpg_uploadFlow1" doc:name="rpg_uploadFlow1">
<file:inbound-endpoint path="C:\Users\Claes\Documents\CD-utveckling\paper-rpg\OUT" moveToDirectory="C:\Users\Claes\Documents\CD-utveckling\paper-rpg\sent" responseTimeout="10000" mimeType="text/xml" doc:name="File"/>
<http:outbound-endpoint exchange-pattern="one-way" host="http://XXXXXXXXXXX.ashx?SystemName=XXXX&UserName=XXXX&PassWord=XXXXX" port="80" disableTransportTransformer="true" doc:name="HTTP"/>
</flow>
Error;
ERROR 2013-05-17 17:24:49,208 [[rpg_upload].connector.http.mule.default.dispatcher.07] org.mule.exception.DefaultMessagingExceptionStrategy:
Message : Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=http://http://xxxxxxxxxxxxxxxx/rpgtest/service.ashx? SystemName=xxxxxxxxxxxxxxxxx&UserName=xxxxxxxxxxxxxxx&PassWord=xxxxxxx, connector=HttpConnector
{
name=connector.http.mule.default
lifecycle=start
this=18b44ce0
numberOfConcurrentTransactedReceivers=4
createMultipleTransactedReceivers=true
connected=true
supportedProtocols=[http]
serviceOverrides=<none>
}
, name='endpoint.http.http.xxxxxxxxxxxxxxxx.service.ashx.SystemName.xxxxx.UserName.xxxxx.Pass Word.836749.80', mep=ONE_WAY, properties={PassWord=836749:80, SystemName=xxxxxx, UserName=xxxxxxxxx}, transactionConfig=Transaction{factory=null, action=INDIFFERENT, timeout=0}, deleteUnacceptedMessages=false, initialState=started, responseTimeout=10000, endpointEncoding=UTF-8, disableTransportTransformer=true}. Message payload is of type: ReceiverFileInputStream
Code : MULE_ERROR-42999
--------------------------------------------------------------------------------
Exception stack is:
1. http (java.net.UnknownHostException)
java.net.AbstractPlainSocketImpl:-1 (null)
2. Failed to route event via endpoint: DefaultOutboundEndpoint{endpointUri=http://http://xxxxxxxxxx.ashx? SystemName=xxxxxxxxxxxx&UserName=xxxxxx&PassWord=836749:80, connector=HttpConnector
{
name=connector.http.mule.default
lifecycle=start
this=18b44ce0
numberOfConcurrentTransactedReceivers=4
createMultipleTransactedReceivers=true
connected=true
supportedProtocols=[http]
serviceOverrides=<none>
}
, name='endpoint.http.http.xxxx.ashx.SystemName.xxxxxxxx.UserName.xxxxx.PassWord.836749.80', mep=ONE_WAY, properties={PassWord=836749:80, SystemName=xxxxxxxxxx, UserName=xxxx}, transactionConfig=Transaction{factory=null, action=INDIFFERENT, timeout=0}, deleteUnacceptedMessages=false, initialState=started, responseTimeout=10000, endpointEncoding=UTF-8, disableTransportTransformer=true}. Message payload is of type: ReceiverFileInputStream (org.mule.api.transport.DispatchException)
org.mule.transport.http.HttpClientMessageDispatcher:155 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/transport/DispatchExceptio n.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.net.UnknownHostException: http
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
I have had trouble in some spots with the file endpoint because it passes along a filereader as the payload instead of the actual text. Try adding a file-to-string converter:
<flow name="rpg_uploadFlow1" doc:name="rpg_uploadFlow1">
<file:inbound-endpoint path="C:\Users\Claes\Documents\CD-utveckling\paper-rpg\OUT" moveToDirectory="C:\Users\Claes\Documents\CD-utveckling\paper-rpg\sent" responseTimeout="10000" mimeType="text/xml" doc:name="File"/>
<file:file-to-string-transformer doc:name="File to String"/>
<http:outbound-endpoint exchange-pattern="one-way" host="http://XXXXXXXXXXX.ashx?SystemName=XXXX&UserName=XXXX&PassWord=XXXXX" port="80" disableTransportTransformer="true" doc:name="HTTP"/>
</flow>
You can use a mule byte array to string transformer to make your request as string and then post it to your http outbound.
<flow name="rpg_uploadFlow1" doc:name="rpg_uploadFlow1">
<file:inbound-endpoint path="C:\Users\Claes\Documents\CD-utveckling\paper-rpg\OUT" moveToDirectory="C:\Users\Claes\Documents\CD-utveckling\paper-rpg\sent" responseTimeout="10000" mimeType="text/xml" doc:name="File"/>
<byte-array-to-string-transformer></byte-array-to-string-transformer>
.....
Coming to your error. I gues it is not related to mule tags and endpoints. It is something in accessing the url you are trying.
See the below post for the issue related to UnknownHostException.
java.net.UnknownHostException when accessing a URL
Try this:
You can use a mule byte array to string transformer to make your requested File as string and then use SetPayload or Attachment Connector and post it to your http outbound.
Related
I need to send an acknowledge response for some messages went an acknowledge needed flag is set for that purpose.
Using a Java component I build a Payload string array with this structure:
Payload[0]=message entry.
Payload[1]="true"/"false" // This is the acknowledge needed flag.
Payload[2]="OK"/"ON"/"OFF"// Response to the transport (went flag="true")
This is my XML code
<tcp:connector name="TCP" validateConnections="false" sendBufferSize="0" receiveBufferSize="0" receiveBacklog="0" keepAlive="true" clientSoTimeout="10000" serverSoTimeout="10000" socketSoLinger="0" doc:name="TCP">
<tcp:direct-protocol rethrowExceptionOnRead="true" payloadOnly="true"/>
</tcp:connector>
<flow name="verifyFlow">
<tcp:inbound-endpoint exchange-pattern="request-response" host="localhost" port="9446" connector-ref="TCP" responseTimeout="10000" doc:name="TCP" transformer-refs="Byte_Array_to_String"/>
<component class="verify.as" doc:name="Java Component"/>
<choice doc:name="Choice">
<when expression="#[message.payload[1] == 'false']">
<set-payload value="""" doc:name="No response"/>
</when>
<otherwise>
<expression-transformer mimeType="text/plain" expression="#[message.payload[2]]" doc:name="Expression"/>
</otherwise>
</choice>
</flow>
The problem I'm facing is that went ever the flag is "false" there shouldn't be any response send to the transport (no 'null' value, no empty string, no "", Etc.) ¿Is there any way to change the exchange pattern of the TCP (or UDP) connector from request-response to one way inside the flow?
i am building a simple restful proxy using mule. while majority of the rest calls are proxied properly, one of the POST call is throwing a null pointer exception.
Here's the message inbound:
org.mule.DefaultMuleMessage
{
id=c856d080-bd55-11e4-8504-6c40089d7cb6
payload=java.lang.String
correlationId=<not set>
correlationGroup=-1
correlationSeq=-1
encoding=UTF-8
exceptionPayload=<not set>
Message properties:
INVOCATION scoped properties:
INBOUND scoped properties:
accept=text/virl+xml,multipart/mixed
authorization=Basic TmV0U2ltOk5ldFNpbQ==
connection=keep-alive
content-length=1000
content-type=application/xml
host=localhost:9090
http.listener.path=/*
http.method=POST
http.query.params=org.mule.module.http.internal.ParameterMap#330eee18
http.query.string=session=0c603343-49e6-452f-bfdf-1e69cf478f65
http.remote.address=/127.0.0.1:52065
http.request.path=/ank/rest/process
http.request.uri=/ank/rest/process?session=0c603343-49e6-452f-bfdf-1e69cf478f65
http.scheme=http
http.uri.params=org.mule.module.http.internal.ParameterMap#0
http.version=HTTP/1.1
user-agent=Jersey/2.0-rc1 (HttpUrlConnection 1.7.0_71)
OUTBOUND scoped properties:
Content-Type=text/plain;charset=UTF-8
MULE_ENCODING=UTF-8
http.disable.status.code.exception.check=false
SESSION scoped properties:
}
ERROR 2015-02-25 19:21:26,894 [[restproxy].VIRL-UWM-Management-APIs.worker.02] org.mule.exception.CatchMessagingExceptionStrategy:
********************************************************************************
Message : null (java.lang.NullPointerException). Message payload is of type: String
Code : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. null (java.lang.NullPointerException)
org.mule.module.http.internal.HttpParser:94 (null)
2. null (java.lang.NullPointerException). Message payload is of type: String (org.mule.api.MessagingException)
org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor:32 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.lang.NullPointerException
at org.mule.module.http.internal.HttpParser.parseMultipartContent(HttpParser.java:94)
at org.mule.module.http.internal.request.HttpResponseToMuleEvent.getInboundAttachments(HttpResponseToMuleEvent.java:139)
at org.mule.module.http.internal.request.HttpResponseToMuleEvent.convert(HttpResponseToMuleEvent.java:77)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
Have no clue why is it failing. Hitting the actual end point by-passing the proxy works properly. any clues ?
Mule flow:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting" 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.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/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/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">
<http:listener-config name="VIRL-UWM-Management-APIs" host="0.0.0.0" port="9090" doc:name="HTTP Listener Configuration"/>
<http:request-config name="Actual-Virl-Enpoint-for-UWM" host="virl03.stic.cisco-services.com" port="19399" doc:name="HTTP Request Configuration"/>
<http:listener-config name="AutoNetKit-API" host="0.0.0.0" port="19401" doc:name="HTTP Listener Configuration"/>
<http:request-config name="AutoNetkit-End-Point" host="virl03.stic.cisco-services.com" port="19401" doc:name="HTTP Request Configuration"/>
<flow name="virl-proxyFlow">
<http:listener config-ref="AutoNetKit-API" path="*" allowedMethods="GET" doc:name="HTTP"/>
<set-property propertyName="http.disable.status.code.exception.check" value="false" doc:name="Disable Exception Check"/>
<logger message=" payload is: #[message.payload], method is: #[message.inboundProperties.'http.method'], Request URI is: #[message.inboundProperties.'http.request.uri'], message is: #[message]" level="INFO" doc:name="Logger"/>
<flow-ref name="copy-headers" doc:name="Copy HTTP Headers"/>
<http:request config-ref="AutoNetkit-End-Point" path="#[message.inboundProperties.'http.request.uri']" method="#[message.inboundProperties.'http.method']" responseTimeout="60000" doc:name="AutoNetKit-EndPoint"/>
<flow-ref name="copy-headers" doc:name="Copy HTTP Headers"/>
</flow>
<flow name="VIRL-Restful-Proxy">
<http:listener config-ref="VIRL-UWM-Management-APIs" path="*" doc:name="HTTP"/>
<choice doc:name="GET-vs-POST">
<when expression="#[message.inboundProperties.'http.method' == 'POST']">
<object-to-string-transformer doc:name="Object to String"/>
<logger message="Set the payload of type string - since it's a post request." level="INFO" doc:name="Logger"/>
</when>
<otherwise>
<logger message="Not setting payload transformation as it's a GET request." level="INFO" doc:name="Logger"/>
</otherwise>
</choice>
<set-property propertyName="http.disable.status.code.exception.check" value="false" doc:name="Disable Exception Check"/>
<logger message=" payload is: #[message.payload], method is: #[message.inboundProperties.'http.method'], Request URI is: #[message.inboundProperties.'http.request.uri'], message is: #[message]" level="INFO" doc:name="Logger"/>
<flow-ref name="copy-headers" doc:name="Copy HTTP Headers"/>
<http:request config-ref="Actual-Virl-Enpoint-for-UWM" path="#[message.inboundProperties.'http.request.uri']"
method="#[message.inboundProperties.'http.method']" responseTimeout="60000" doc:name="VIRL End Point"/>
<logger message="response payload: #[message]" level="INFO" doc:name="Logger"/>
<flow-ref name="copy-headers" doc:name="Copy HTTP Headers"/>
<catch-exception-strategy doc:name="Catch Exception Strategy">
<logger level="DEBUG" message="#[exception.exceptions]" doc:name="Logger"/>
</catch-exception-strategy>
</flow>
<sub-flow name="copy-headers" >
<copy-properties propertyName="*" doc:name="Copy All HTTP Headers"/>
<remove-property propertyName="Content-Length" doc:name="Remove Content Length"/>
<remove-property propertyName="MULE_*" doc:name="Remove MULE Properties"/>
<remove-property propertyName="X_MULE*" doc:name="Remove X_MULE Properties"/>
<remove-property propertyName="X-MULE*" doc:name="Remove X-MULE Properties"/>
</sub-flow>
</mule>
thanks
This is a bug in Mule's code: I've reported it as such, you can track MULE-8342.
In the meantime, you can try the following:
If you have control of the remote server, add a Content-Disposition header in its multipart responses.
Temporarily use an http:outbound-endpoint in lieu of http:request, until the above bug is fixed.
My mule application is receiving a HTTP POST request with the Content-Type as multipart/form-data. I tried to use a custom transformer but do not know how to access the paramters as the object is of class ContentLengthInputStream.
How do I access the form parameters?
I want to convert the parameters into a map. How do I do this?
you can use #[message.inboundAttachments[payload] in a flow, for example, to send a http outbound endpoint:
<message-properties-transformer doc:name="Message">
<add-message-property key="Content-type" value="multipart/form-data/>
</message-properties-transformer>
<http:outbound-endpoint exchange-pattern="request-response" method="POST" doc:name="HTTP" address="http://localhost:9090" mimeType="multipart/form-data"/>
To receive can be used:
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8090" connector-ref="HTTP_HTTPS" doc:name="HTTP" contentType="multipart/form-data"/>
<logger message="#[message.inboundAttachments[payload]]" level="ERROR" doc:name="Logger"/>
You can use a transformer(AbstractMessageTransformer) and get the payload with:
DataHandler inboundAttachment = message.getInboundAttachment("AttachmentName");
I've created a simple flow that exposes an HTTP endpoint linked to a REST service. The REST service returns a String which is then placed onto a JMS queue using the request-response pattern. The idea is that the String placed on the queue will be consumed by some consumer and a reponse will created using the Reply-To address. So basically this is implimenting synchronous JMS.
The flow works as expected, except when the HTTP endpoint is secured using Basic Authentication. In this case the response is:
java.io.NotSerializableException: com.sun.jersey.spi.container.ContainerResponse (org.apache.commons.lang.SerializationException). Message payload is of type: MuleResponseWriter$1
and no message is placed on the queue. Removing Basic Authentication results in no exception being thrown. Also, removing the JMS outbound endpoint results in the String being echoed back which leads me to believe the problem is with the JMS endpoint. I suspect that the problem is with the response from the JMS endpoint because setting component in the flow to one-way negates the problem. I think the issue might be that the endpoint is sending some response to the HTTP endpoint without authentication credentials and it fails because of it, but I'm unsure how to deal with this.
Below is the flow that I created:
<mule
xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting"
xmlns:context="http://www.springframework.org/schema/context" xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:jms="http://www.mulesoft.org/schema/mule/jms"
xmlns:jersey="http://www.mulesoft.org/schema/mule/jersey"
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"
version="CE-3.3.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mule-ss="http://www.mulesoft.org/schema/mule/spring-security"
xmlns:json="http://www.mulesoft.org/schema/mule/json"
xmlns:ss="http://www.springframework.org/schema/security" 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/jms http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd
http://www.mulesoft.org/schema/mule/jersey http://www.mulesoft.org/schema/mule/jersey/current/mule-jersey.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/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd
http://www.mulesoft.org/schema/mule/spring-security http://www.mulesoft.org/schema/mule/spring-security/3.1/mule-spring-security.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd ">
<jms:activemq-connector name="Active_MQ" specification="1.1" brokerURL="tcp://localhost:61616"
validateConnections="true" doc:name="Active MQ"/>
<mule-ss:security-manager>
<mule-ss:delegate-security-provider name="memory-provider" delegate-ref="authenticationManager"/>
</mule-ss:security-manager>
<spring:beans>
<ss:authentication-manager alias="authenticationManager">
<ss:authentication-provider>
<ss:user-service id="userService">
<ss:user name="username" password="password" authorities="ROLE_ADMIN"/>
</ss:user-service>
</ss:authentication-provider>
</ss:authentication-manager>
</spring:beans>
<flow name="RESTAPISync" doc:name="RESTAPISync">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP">
<mule-ss:http-security-filter realm="realm"/>
</http:inbound-endpoint>
<jersey:resources doc:name="REST">
<component class="SFREST"/>
</jersey:resources>
<jms:outbound-endpoint exchange-pattern="request-response" queue="tmp" connector-ref="Active_MQ"
doc:name="JMS"/>
</flow>
The SFREST.java component:
import javax.ws.rs.GET;
import javax.ws.rs.Path;
#Path("/pops")
public class SFREST{
#GET
public String getPOPs() throws Exception{
return "hello";
}
}
And the exception:
ERROR 2012-11-04 21:40:57,485 [[jmstest].connector.http.mule.default.receiver.02] org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : Authentication Attempt Failed. Message payload is of type: String
Code : MULE_ERROR-54999
--------------------------------------------------------------------------------
Exception stack is:
1. Bad credentials (org.springframework.security.authentication.BadCredentialsException)
org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider:137 (null)
2. Authentication Attempt Failed. Message payload is of type: String (org.mule.api.security.UnauthorisedException)
org.mule.security.MuleSecurityManager:96 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/security/UnauthorisedException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
org.springframework.security.authentication.BadCredentialsException: Bad credentials
at org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider.authenticate(AbstractUserDetailsAuthenticationProvider.java:137)
at org.springframework.security.authentication.ProviderManager.authenticate(ProviderManager.java:156)
at org.mule.module.spring.security.SpringProviderAdapter.authenticate(SpringProviderAdapter.java:70)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
ERROR 2012-11-04 21:41:04,522 [[jmstest].connector.http.mule.default.receiver.02] org.mule.exception.DefaultMessagingExceptionStrategy:
********************************************************************************
Message : java.io.NotSerializableException: com.sun.jersey.spi.container.ContainerResponse (org.apache.commons.lang.SerializationException). Message payload is of type: MuleResponseWriter$1
Code : MULE_ERROR-29999
--------------------------------------------------------------------------------
Exception stack is:
1. com.sun.jersey.spi.container.ContainerResponse (java.io.NotSerializableException)
java.io.ObjectOutputStream:1164 (null)
2. java.io.NotSerializableException: com.sun.jersey.spi.container.ContainerResponse (org.apache.commons.lang.SerializationException)
org.apache.commons.lang.SerializationUtils:111 (null)
3. java.io.NotSerializableException: com.sun.jersey.spi.container.ContainerResponse (org.apache.commons.lang.SerializationException). Message payload is of type: MuleResponseWriter$1 (org.mule.api.MessagingException)
org.mule.execution.ExceptionToMessagingExceptionExecutionInterceptor:35 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.io.NotSerializableException: com.sun.jersey.spi.container.ContainerResponse
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1164)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)
at org.apache.commons.collections.map.AbstractHashedMap.doWriteObject(AbstractHashedMap.java:1182)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************
Any ideas?
Turns out the problem was that the jersey_response property can't be serialized and needs to be removed. So regardless of what the payload is as long as this property is in the message, the message can't be passed to the JMS outbound component. More info can be found at:
http://forum.mulesoft.org/mulesoft/topics/http_authentication_with_jms_request_response?utm_content=topic_link&utm_medium=email&utm_source=reply_notification
The reason of the exception is because any jersey component returns a com.sun.jersey.spi.container.ContainerResponse that you need to transform before propagating it to the next message processor as explained here
I have defined a Mule HTTP Inbound Endpoint as :
<flow name="jfeed_fill_data">
<http:inbound-endpoint address="http://localhost:1212/jcore/insert/feed/">
</http:inbound-endpoint>
<component class="main.java.com.joshlabs.jcore.Feed"/>
</flow>
Now this Service Works Fine.
But When i type a Deformed URL , something like "http://localhost:1212/jcore/insert/feedasdasdAwes/", I get the following Message from MULE :
Cannot bind to address "http://localhost:1212/jcore/insert/feedasdasdAwes/"
No component registered on that endpoint
My Question is : How can i Change the above default Message to Something of my own.?
Note : Actually i wanted to return a JSON String as an Error message. Something like :
{
Exception: "Invalid URL"
}
And if possible, then "Can MULE throw HTTP 404 : Not Found Error in above case"..??
You just need to make your endpoint accept all sub-paths and then handle wrong ones with message routing:
<flow name="jfeed_fill_data">
<http:inbound-endpoint address="http://localhost:1212" />
<choice>
<when evaluator="header" expression="INBOUND:http.request.path=/jcore/insert/feed/">
<component class="main.java.com.joshlabs.jcore.Feed"/>
</when>
<otherwise>
<message-properties-transformer>
<add-message-property key="http.status" value="404"/>
</message-properties-transformer>
<expression-transformer>
<return-argument evaluator="string" expression="{Exception: "Invalid URL"}"/>
</expression-transformer>
</otherwise>
</choice>
</flow>