I am new to Mule and trying to post a GET request using the HTTP endpoint, but I am receiving the following error
"Template Endpoint "http://api.mymemory.translated.net:80/get?q=#[message.inboundProperties.get('http.relative.path')]&langpair=EN|IT" resolved into a Malformed endpoint "http://api.mymemory.translated.net:80/get?q=hello&langpair=EN|IT". Failed to route event via endpoint: org.mule.endpoint.DynamicOutboundEndpoint"
I have tried the following configurations:
get?q=hello&langpair=EN%7CIT [WORKS]
get?q=#[message.inboundProperties.get('http.relative.path')]&langpair=EN%7CIT [DOESN'T WORK]
get?q=#[message.inboundProperties.get('http.relative.path')]&langpair=EN|IT
[DOESN'T WORK]
The stack trace seems to indicate that there is a problem with the "|" character.
My flow is as follows:
<flow name="my_first_projectFlow1" doc:name="my_first_projectFlow1">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP"/>
<http:outbound-endpoint exchange-pattern="request-response" host="api.mymemory.translated.net" port="80" path="get?q=#[message.inboundProperties.get('http.relative.path')]&langpair=EN%7CIT" method="GET" doc:name="HTTP"/>
<echo-component doc:name="Echo"/>
</flow>
Try replacing the pipe ("|") char with MEL expression #[java.net.URLEncoder.encode('|', 'UTF-8')].
Related
Im doing a sample bookstore. When the user has booked a order, the system send him an email with the dates from the order. The system send the email but it shows the next error:
Root Exception stack trace:
java.lang.IllegalArgumentException: Cannot apply transformer HttpClientMethodResponseToObject{this=6911a11b, name='HttpClientMethodResponseToPedido', ignoreBadInput=false, returnClass=SimpleDataType{type=org.mule.entities.Pedido, mimeType='text/html'}, sourceTypes=[SimpleDataType{type=org.apache.commons.httpclient.HttpMethod, mimeType='*/*'}]} on source payload: class org.mule.transport.http.HttpResponse
at org.mule.DefaultMuleMessage.applyAllTransformers(DefaultMuleMessage.java:1427)
at org.mule.DefaultMuleMessage.applyTransformers(DefaultMuleMessage.java:1379)
at org.mule.DefaultMuleMessage.applyTransformers(DefaultMuleMessage.java:1371)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
My XML is the next:
<smtp:gmail-connector name="Gmail" validateConnections="true" doc:name="Gmail" contentType="text/html" />
<flow name="Email" doc:name="Email">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8088" doc:name="HTTP" path="Email"/>
<http:static-resource-handler resourceBase="docroot" defaultFile="index.html" doc:name="HTTP Static Resource Handler"/>
</flow>
<flow name="Correo" doc:name="Correo">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8088" path="Facturacion" doc:name="HTTP" transformer-refs="Java"/>
<component doc:name="Generar Pedido" class="org.mule.components.GenerarPedido"/>
<smtp:outbound-endpoint host="smtp.gmail.com" port="587" user="email%40gmail.com" password="pass" connector-ref="Gmail" to="#[payload.email]" from="BookStore S.A." responseTimeout="10000" doc:name="SMTP" transformer-refs="Java1" mimeType="text/html"/>
<http:response-builder status="200" contentType="text/html" doc:name="HTTP Response Builder"/>
<http:http-response-to-object-transformer returnClass="org.mule.entities.Pedido" encoding="UTF-8" mimeType="text/html" doc:name="HTTP Response to Object"/>
</flow>
Anyone can help me?
Your payload is not a HTTP response, so you cannot use the http-response-to-object-transformer. This is used after calling an http:outbound-endpoint which returns a 'HTTP response'.
I have a problem sending and receiving messages using Mule SQS Connector. Mule starts ok but throws javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated exception when i try to send or receive messages.
I am using keystores for other https outbounds.
Here is my flow
<sqs:config name="Amazon_SQS" accessKey="${AMAZON.ACCESS.KEY}"
secretKey="${AMAZON.SECRET.KEY}" queueName="${AMAZON.QUEUE.NAME}"
doc:name="Amazon SQS">
</sqs:config>
<flow name="TestFlow" doc:name="TestFlow">
<http:inbound-endpoint exchange-pattern="request-response"
host="localhost" port="8081" path="post" doc:name="HTTP" />
<set-payload
value="#['hello']"
doc:name="Set Payload" />
<json:object-to-json-transformer
doc:name="Object to JSON" />
<sqs:send-message config-ref="Amazon_SQS" doc:name="Amazon SQS"/>
</flow>
Per this question Getting "peer not authenticated" exception on Amazon SQS I'm wondering what JRE are you using? Do you have a recent Oracle JRE?
Per this blog post http://myjavacodeworld.blogspot.ca/2012/12/javaxnetsslsslpeerunverifiedexception.html, it seems you could use -Dcom.amazonaws.sdk.disableCertChecking=true to bypass the issue.
Hi guys first of all I want you to see my wsdl file it's DHL24 api I want learn a bit on this and use simple example here is the link https://dhl24.com.pl/webapi.html
I want to use getVersion as you can see we don't need to provide any data to this only in response we have getVersionResult - STRING
First of all I created package generated from apache CTX using simple project here is POM:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>pl.test</groupId>
<artifactId>DhlServiceClient</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<apache.cxf-version>2.5.9</apache.cxf-version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${apache.cxf-version}</version>
<executions>
<execution>
<id>Wsdl2Java - gasShopService.wsdl</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${basedir}/src/main/java/</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/dhlService.wsdl</wsdl>
<extraargs>
<extraarg>-client</extraarg>
<extraarg>-autoNameResolution</extraarg>
<extraarg>-p</extraarg>
<extraarg>pl.test</extraarg>
<extraarg>-aer=false</extraarg>
<extraarg>-verbose</extraarg>
<extraarg>-frontend</extraarg>
<extraarg>jaxws21</extraarg>
<extraarg>-wsdlLocation </extraarg>
<extraarg>classpath:dhlService.wsdl</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
All is fine here I have package and classes so I start to create second project (as dependency I added this package - this works fine)
Now I want to create simple flow:
<flow name="getVersion" doc:name="getVersion">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8088" path="getVersion" doc:name="HTTP"/>
<logger doc:name="getVersion" message="Test Before" level="ERROR"/>
<cxf:jaxws-client operation="getVersion" clientClass="pl.test.integration.dhl.ws.client.DHL24WebapiService" port="DHL24WebapiPort" enableMuleSoapHeaders="true" doc:name="SOAP">
</cxf:jaxws-client>
<logger doc:name="getVersion" message="Test after" level="ERROR"/>
</flow>
Nothing big but when I post to this I have:
ERROR 2014-06-28 20:36:10,289
[[gaspoldhlservice].connector.http.mule.default.receiver.02]
org.mule.api.processor.LoggerMessageProcessor: Test Before ERROR
2014-06-28 20:36:10,291
[[gaspoldhlservice].connector.http.mule.default.receiver.02]
org.mule.exception.DefaultMessagingExceptionStrategy:
**************************************************************************** Message : wrong number of arguments. Failed to route
event via endpoint: org.mule.module.cxf.CxfOutboundMessageProcessor.
Message payload is of type: ContentLengthInputStream Code
: MULE_ERROR--2
-------------------------------------------------------------------------------- Exception stack is:
1. wrong number of arguments (java.lang.IllegalArgumentException) sun.reflect.NativeMethodAccessorImpl:-2 (null)
2. wrong number of arguments. Failed to route event via endpoint: org.mule.module.cxf.CxfOutboundMessageProcessor. Message payload is of
type: ContentLengthInputStream
(org.mule.api.transport.DispatchException)
org.mule.module.cxf.CxfOutboundMessageProcessor:150
-------------------------------------------------------------------------------- Root Exception stack trace: java.lang.IllegalArgumentException: wrong
number of arguments at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
I was searching a bit in google and found something like this. I add after inbound:
<object-to-byte-array-transformer />
And I had other error:
ERROR 2014-06-28 20:45:18,149
[[gaspoldhlservice].connector.http.mule.default.receiver.02]
org.mule.api.processor.LoggerMessageProcessor: Test Before ERROR
2014-06-28 20:45:18,151
[[gaspoldhlservice].connector.http.mule.default.receiver.02]
org.mule.exception.DefaultMessagingExceptionStrategy:
**************************************************************************** Message : wrong number of arguments. Failed to route
event via endpoint: org.mule.module.cxf.CxfOutboundMessageProcessor.
Message payload is of type: byte[] Code :
MULE_ERROR--2
-------------------------------------------------------------------------------- Exception stack is:
1. wrong number of arguments (java.lang.IllegalArgumentException) sun.reflect.NativeMethodAccessorImpl:-2 (null)
2. wrong number of arguments. Failed to route event via endpoint: org.mule.module.cxf.CxfOutboundMessageProcessor. Message payload is of
type: byte[] (org.mule.api.transport.DispatchException)
org.mule.module.cxf.CxfOutboundMessageProcessor:150
-------------------------------------------------------------------------------- Root Exception stack trace: java.lang.IllegalArgumentException: wrong
number of arguments at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
I need a little bit push here its very simple method and I cant handle it right ...
AFTER EDIT:
Changed to your flow with:
<flow name="getVersion" doc:name="getVersion">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8088" path="getVersion" doc:name="HTTP"/>
<cxf:jaxws-client operation="getVersion" serviceClass="pl.test.integration.dhl.ws.client.DHL24WebapiService" port="DHL24WebapiPort" enableMuleSoapHeaders="true" doc:name="SOAP">
</cxf:jaxws-client>
<http:outbound-endpoint exchange-pattern="request-response" address="http://localhost:8088/consumeTest" doc:name="HTTP" method="POST"/>
</flow>
<flow name="consumeTest" doc:name="consumeTest">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8088" path="consumeTest" doc:name="HTTP"/>
<logger doc:name="getVersion" message="Test AFTER" level="ERROR"/>
</flow>
Answer is
No such operation: getVersion. Failed to route event via endpoint:
org.mule.module.cxf.CxfOutboundMessageProcessor. Message payload is of
type: ContentLengthInputStream
When I use clientClass instead of serviceClass:
wrong number of arguments. Failed to route event via endpoint:
org.mule.module.cxf.CxfOutboundMessageProcessor. Message payload is of
type: ContentLengthInputStream
You need to put an outbound endpoint after cxf:jaxws-client like
<http:outbound-endpoint exchange-pattern="request-response" address="Your external webservice path that you are tying to consume " doc:name="HTTP" method="POST"/> to post the value to the external webservice ..
for example If your external webservice is at http://localhost:8086/mainData?wsdl then you need to put
<http:outbound-endpoint exchange-pattern="request-response" address="http://localhost:8086/mainData" doc:name="HTTP" method="POST"/> ................ and one more thing ... could you plase change
<cxf:jaxws-client operation="getVersion" clientClass="pl.execon.integration.dhl.ws.client.DHL24WebapiService" port="DHL24WebapiPort" enableMuleSoapHeaders="true" doc:name="SOAP"> to
`<cxf:jaxws-client operation="getVersion" serviceClass="pl.execon.integration.dhl.ws.client.DHL24WebapiService" port="DHL24WebapiPort" enableMuleSoapHeaders="true" doc:name="SOAP">` in your flow and try ...
So the final flow would be something like :-
<flow name="getVersion" doc:name="getVersion">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8088" path="getVersion" doc:name="HTTP"/>
<cxf:jaxws-client operation="getVersion" serviceClass="pl.execon.integration.dhl.ws.client.DHL24WebapiService" port="DHL24WebapiPort" enableMuleSoapHeaders="true" doc:name="SOAP">
</cxf:jaxws-client>
<http:outbound-endpoint exchange-pattern="request-response" address="Your external webservice path that you are tying to consume " doc:name="HTTP" method="POST"/>
</flow>
AFTER EDIT:
Changed to your flow with:
<flow name="getVersion" doc:name="getVersion">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8088" path="getVersion" doc:name="HTTP"/>
<cxf:jaxws-client operation="getVersion" serviceClass="pl.test.integration.dhl.ws.client.DHL24WebapiService" port="DHL24WebapiPort" enableMuleSoapHeaders="true" doc:name="SOAP">
</cxf:jaxws-client>
<http:outbound-endpoint exchange-pattern="request-response" address="http://localhost:8088/consumeTest" doc:name="HTTP" method="POST"/>
</flow>
<flow name="consumeTest" doc:name="consumeTest">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8088" path="consumeTest" doc:name="HTTP"/>
<logger doc:name="getVersion" message="Test AFTER" level="ERROR"/>
</flow>
Answer is
No such operation: getVersion. Failed to route event via endpoint:
org.mule.module.cxf.CxfOutboundMessageProcessor. Message payload is of
type: ContentLengthInputStream
When I use clientClass instead of serviceClass:
wrong number of arguments. Failed to route event via endpoint:
org.mule.module.cxf.CxfOutboundMessageProcessor. Message payload is of
type: ContentLengthInputStream
I'm new to mule and working on a POC. I want to enrich the payload(target.xml) by calling an http endpoint which returns xml as response (source.xml) .
<flow name="mule-configFlow" doc:name="mule-configFlow">
<jms:inbound-endpoint doc:name="JMS" connector-ref="Active_MQ" queue="QUEUE1"/>
<logger message="#[message.payload]" level="INFO" doc:name="Logger"/>
<enricher doc:name="Message Enricher" target="#[xpath:Customer/OfficeId]">
<http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="8095" path="myservice/v1/" method="GET" doc:name="HTTP">
<expression-transformer evaluator="xpath" expression="Response/OffId" />
</http:outbound-endpoint>
</enricher>
<jms:outbound-endpoint queue="QUEUE2" connector-ref="Active_MQ" doc:name="JMS"/>
</flow>
I've verified and http endpoint works fine but I'm getting the below error
Expression Evaluator "xpath" with expression "Response/OffId" returned null but a value was required
Am i configuring the source and target expression correctly ?
Incoming Message payload (target.xml):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Customer xmlns="http://www.xyz.com/abc/v1">
<ActionType>ACCOUNT_ADDED</ActionType>
<OfficeId></OfficeId>
<MemberId></MemberId>
</Customer>
Source for enrichment (source.xml):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Response xmlns="http://www.xyz.com/abc/v1">
<OffId></OffId>
<MemId></MemId>
</Response>
There's a couple of issues here:
your expression transformer will not work inside the outbound endpoint
your xpath expression will not work due to the xmlns ref in the xml
you can not transform an xml string with an enhancer
To make this work, put the outbound endpoint and the expression transporter inside a process-chain, use an xpath expression that either handles namespaces or ignores them, and transform your initial xml string payload to something else, for example DOM, that you can manipulate.
Something like this should work:
<mulexml:xml-to-dom-transformer returnClass="org.dom4j.Document"/>
<enricher source="#[payload]" target="#[payload.rootElement.element('OfficeId').text]">
<processor-chain>
<http:outbound-endpoint exchange-pattern="request-response" host="localhost" port="8095" path="myservice/v1/" method="GET"/>
<expression-transformer evaluator="xpath" expression="//*[local-name()='OffId']" />
</processor-chain>
</enricher>
My web application is on following address:
http://localhost:8080/MyProject/page-obj.html
I am calling Mule Project, from a Web Application(deployed on glassfish), having following URL in page:
`<form action="http://localhost:28146/CallObject" method="post" id="objform">`
Mule project is executing something on remote server and returning Success.
I want to redirect success to another page say
http://localhost:8080/MyProject/page-sucess.html
When redirect, i see http://localhost:28146/CallObject on address bar, instead of http://localhost:8080/MyProject/page-sucess.html. Secondly, i am unable to load CSS and JS properly. I think i am not handling this properly
Following is Mule Flow in use:
`
<http:endpoint exchange-pattern="request-response" address="http://localhost:8080/MyProject/page-sucess.html" name="page" method="POST"/>
<flow name="Create_Work_Flow" doc:name="Create_Work_Flow">
<http:inbound-endpoint exchange-pattern="request-response" address="http://localhost:28146/CallObject" contentType="text/html" doc:name="Request">
<http:body-to-parameter-map-transformer doc:name="HTMLForm-Parameters-To-Mule"/>
</http:inbound-endpoint>
<logger level="INFO" doc:name="Form-Parameters" message="#[payload]" />
<http:outbound-endpoint exchange-pattern="request-response" method="POST" doc:name="HTTP" ref="Page">
<custom-transformer class="com.ExecuteWorkflow" doc:name="Call-CreateWorkflow"/>
</http:outbound-endpoint>
</flow>`
Have your Mule flow set redirect headers in the success case and the browser should follow the redirect:
<flow name="Create_Work_Flow" doc:name="Create_Work_Flow">
<http:inbound-endpoint exchange-pattern="request-response" address="http://localhost:28146/CallObject" contentType="text/html" doc:name="Request">
<http:body-to-parameter-map-transformer doc:name="HTMLForm-Parameters-To-Mule"/>
</http:inbound-endpoint>
<logger level="INFO" doc:name="Form-Parameters" message="#[payload]" />
<http:outbound-endpoint exchange-pattern="request-response" method="POST" doc:name="HTTP" ref="Page">
<custom-transformer class="com.ExecuteWorkflow" doc:name="Call-CreateWorkflow"/>
</http:outbound-endpoint>
<set-property propertyName="http.status" value="301"/>
<set-property propertyName="Location" value="http://localhost:8080/MyProject/page-
</flow>