I am trying to get the basic http rest helloworld example working in Mule but I get this error
Could not find a transformer to transform "SimpleDataType{type=java.lang.String, mimeType='*/*'}" to "SimpleDataType{type=java.io.InputStream, mimeType='*/*'}". (org.mule.api.transformer.TransformerException). Message payload is of type: String
This is my config file:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:jersey="http://www.mulesoft.org/schema/mule/jersey"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.3/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/3.3/mule-http.xsd
http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/3.3/mule-xml.xsd
http://www.mulesoft.org/schema/mule/jersey http://www.mulesoft.org/schema/mule/jersey/3.0/mule-jersey.xsd
http://jersey.apache.org/core http://jersey.apache.org/schemas/core.xsd">
<flow name="HelloWorld">
<inbound-endpoint address="http://localhost:8081/api"/>
<jersey:resources>
<component class="com.helloworld.AdminApi"/>
</jersey:resources>
</flow>
</mule>
And my jersey service class
#Path("version")
public class AdminApi {
#GET
#Produces("text/plain")
public String sayHelloWithUri() {
return "Version 999 " ;
}
}
I am trying to access the service using:
http://localhost:8081/api/version
which I believe should be the right url but no luck I always get the above exception message.
Anyone has an idea what this could be?
EDIT:
Root Exception stack trace:
org.mule.api.registry.ResolverException: There are two transformers that are an exact match for input: "class java.lang.String", output: "class java.io.InputStream". Transformers are: "_ObjectToInputStream(class org.mule.transformer.simple.ObjectToInputStream)" and "_ObjectToInputStream(class org.mule.transformer.simple.ObjectToInputStream)"
at org.mule.transformer.graph.GraphTransformerResolver.resolve(GraphTransformerResolver.java:65)
at org.mule.registry.TypeBasedTransformerResolver.resolve(TypeBasedTransformerResolver.java:93)
at org.mule.registry.MuleRegistryHelper.resolveTransformer(MuleRegistryHelper.java:265)
+ 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
Your configuration runs just fine with Mule 3.3.0 (tested outside of Tomcat, in Eclipse) so I suspect the problem comes from either missing or duplicated JARs on your web application classpath.
Check the JARs that get packaged in WEB-INF/lib and potential manually added JARs in Tomcat's /lib directory.
<flow name="HelloWorld">
<inbound-endpoint address="http://localhost:8081/api"/>
<jersey:resources>
<component class="com.helloworld.AdminApi"/>
</jersey:resources>
</flow>
and use this url. http://localhost:8081/api/version
result is -Version 999
If you are running with Mule Studio 3.3.0, you must put the mimeType.
Example:
<flow name="RestServiceFlow" doc:name="RestServiceFlow">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8083" doc:name="HTTP" mimeType="application/json"/>
<jersey:resources doc:name="RESTUTCNotification">
<component class="example.esb.restApi"/>
</jersey:resources>
</flow>
Related
I'm new on WSO2 and for a huge project we are using the EI 6.1.1.
One of our goals is to create some REST services that must substitutes some legacy SOAP services: for do that, we are developing Spring Boot REST and our idea is to expose these one in a SOAP way, with same WSDL of the legacy service.
We are creating a Proxy Service on WSO2 and we are able to call the rest service in backend, but, even if the REST logging show us that everything goes fine, the SOAP call never send back response, and "die" with a read timeout.
How can we fix that? I'll post you the proxyService configuration:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="VerificaAmbitiSET_SOAP_AWS"
startOnLoad="true"
statistics="disable"
trace="disable"
transports="http,https">
<target>
<inSequence>
<filter xmlns:ver="http://XXXXXX.XXXXXX.XXXXXX"
xpath="//ver:getAmbitiSet">
<then>
<property expression="//ver:getAmbitiSet/ver:codiceFiscale"
name="REST_URL_POSTFIX"
scope="axis2"
type="STRING"/>
<property name="HTTP_METHOD" scope="axis2" type="STRING" value="GET"/>
</then>
<else/>
</filter>
<header name="Accept" scope="transport" value="*/*"/>
<send>
<endpoint>
<address format="rest"
uri="http://localhost:8280/services/A_SERVICE/ambitiSet"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
</target>
<publishWSDL key="conf:/wsdl/A_WSDL.wsdl"/>
<description/>
</proxy>
and this is the REST controller sign:
#GetMapping(value = "/ambitiSet/{codiceFiscale}")
public List<Ambito> getAmbitiSET(#PathVariable("codiceFiscale") String codiceFiscale)
Finally, my SOAP request looks like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ver="http://XXXX.XXXXX.XXXXXX">
<soapenv:Header/>
<soapenv:Body>
<ver:getAmbitiSet>
<ver:codiceFiscale>XXZXZXZXZ</ver:codiceFiscale>
</ver:getAmbitiSet>
</soapenv:Body>
</soapenv:Envelope>
Greeting.
You can test where the response is getting dropped via enabling wire logs. Please follow the blog https://medium.com/#tharika/how-to-read-and-understand-wire-logs-in-wso2-products-c384af0b8ea5
I am writing a Functional Unit test case to test a Mule Flow containing an inbound and outbound HTTP connector. The flow contains the following components:
An inbound HTTP connector that listens to a rest service call say http://localhost:8080/restapi/id
A logger that displays the id in the logs
A web service consumer that sends the soap request to server2 at the wsdl : http://server2:8080/sample.wsdl
A java component that reads recieves the output from server2 and forms the response for client.
In the functional Unit test case, I am trying to mock the HTTP outbound connector calling the serevr2.
How can I do this?
The flow configuration file code is as below:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:ws="http://www.mulesoft.org/schema/mule/ws" 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"
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/ws http://www.mulesoft.org/schema/mule/ws/current/mule-ws.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd">
<http:request-config name="HTTP_Request_Configuration" host="server2" port="8080" doc:name="HTTP Request Configuration"/>
<ws:consumer-config name="Web_Service_Consumer" wsdlLocation="http://server2:8080/sample.wsdl" service="sample" port="sample" serviceAddress="sample" doc:name="Web Service Consumer"/>
<flow name="samplehttpflowFlow">
<http:listener config-ref="bookmartmanager-httpListenerConfig" path="/restapi/id" allowedMethods="GET" doc:name="HTTP"/>
<logger message="REST request received at #[java.lang.System.currentTimeMillis()]" level="INFO" doc:name="Logger"/>
<ws:consumer config-ref="Web_Service_Consumer" doc:name="Web Service Consumer"/>
<json:xml-to-json-transformer doc:name="XML to JSON"/>
</flow>
</mule>
How am i supposed to disable the amqp-gen queues that creates automatically? in Mule ActiveMQ i got a "disableTemporaryReplyToDestinations" property, by setting that to 'true' and doing a one-way exchange-pattern, i'm able to implement async messaging.
Now with AMQP/RabbitMQ it's a different story, i do have the one-way exchange pattern but i dont have any property to set from the component side inside MuleStudio that tells me to disable those, i can't even disable it from the RabbitMQ Panel.
How do i disable those tempQueues (called amqp-gen in AMQP) which are not needed for an async implementation?
This is my test XML
<mule xmlns:amqp="http://www.mulesoft.org/schema/mule/amqp" 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="CE-3.3.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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/amqp http://www.mulesoft.org/schema/mule/amqp/current/mule-amqp.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 ">
<amqp:connector name="AMQP_Connector" validateConnections="true"
host="arbuzqorks"
port="1111"
fallbackAddresses="localhost:5672"
doc:name="AMQP Connector"/>
<flow name="rabbitmq_demoFlow1" doc:name="rabbitmq_demoFlow1">
<http:inbound-endpoint exchange-pattern="one-way" host="localhost" port="8081" path="rabbitmq" doc:name="HTTP"/>
<set-payload value="#['This is a test message that...']" doc:name="Setting payload"/>
<amqp:outbound-endpoint exchangeType="direct" responseTimeout="10000" doc:name="AMQP" connector-ref="AMQP_Connector" exchangeName="async-direct-test" exchangeDurable="true" queueDurable="true"/>
</flow>
<flow name="async-rabbitmqFlow1" doc:name="async-rabbitmqFlow1">
<amqp:inbound-endpoint exchange-pattern="one-way" exchangeName="async-direct-test" exchangeDurable="true" queueDurable="true" responseTimeout="10000" connector-ref="AMQP_Connector" doc:name="AMQP"/>
<byte-array-to-string-transformer doc:name="Byte Array to String"/>
<set-payload value="#[payload + ' passed into the consumer flow']" doc:name="adding string to payload"/>
<amqp:outbound-endpoint exchange-pattern="one-way" routingKey="test_response" exchangeType="direct" exchangeDurable="true" queueDurable="true" responseTimeout="10000" connector-ref="AMQP_Connector" doc:name="AMQP" exchangeName="async-direct-test"/>
</flow>
<flow name="async-rabbitmqFlow2" doc:name="async-rabbitmqFlow2">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="asyncamqp" doc:name="HTTP"/>
<component class="com.web.esb.component.AsyncMessageRequestorComponent" doc:name="Request AMQP Message"/>
</flow>
</mule>
Your "issue" is not related to temporary queues and trying to disable them but in fact is a feature called "private queues" (see the doc for more information).
Basically, because you do not name the queues you declare in your AMQP inbound and outbound endpoints, RabbitMQ consider them as private to your connection and give them generated names.
Use the queueName attribute to configure queue names on your AMQP endpoints and things will work as you intend.
I am using Spring 3.1.1 with mule.
The versions of the jars used inside mule are 3.1.1 RELEASE.
Inside my configuration XML which is a mule flow,
I am getting following SAX parser exception.
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'context:component-scan'. One of '{"http://www.mulesoft.org/schema/mule/core":annotations, "http://www.mulesoft.org/schema/mule/core":description, "http://www.springframework.org/schema/beans":beans, "http://www.springframework.org/schema/beans":bean, "http://www.springframework.org/schema/context":property-placeholder, "http://www.springframework.org/schema/beans":ref, "http://www.mulesoft.org/schema/mule/core":global-property, "http://www.mulesoft.org/schema/mule/core":configuration, "http://www.mulesoft.org/schema/mule/core":notifications, "http://www.mulesoft.org/schema/mule/core":abstract-extension, "http://www.mulesoft.org/schema/mule/core":abstract-mixed-content-extension, "http://www.mulesoft.org/schema/mule/core":abstract-agent, "http://www.mulesoft.org/schema/mule/core":abstract-security-manager, "http://www.mulesoft.org/schema/mule/core":abstract-transaction-manager, "http://www.mulesoft.org/schema/mule/core":abstract-connector, "http://www.mulesoft.org/schema/mule/core":abstract-global-endpoint, "http://www.mulesoft.org/schema/mule/core":abstract-exception-strategy, "http://www.mulesoft.org/schema/mule/core":abstract-flow-construct, "http://www.mulesoft.org/schema/mule/core":flow, "http://www.mulesoft.org/schema/mule/core":sub-flow, "http://www.mulesoft.org/schema/mule/core":abstract-model, "http://www.mulesoft.org/schema/mule/core":abstract-interceptor-stack, "http://www.mulesoft.org/schema/mule/core":abstract-filter, "http://www.mulesoft.org/schema/mule/core":abstract-transformer, "http://www.mulesoft.org/schema/mule/core":processor-chain, "http://www.mulesoft.org/schema/mule/core":custom-processor, "http://www.mulesoft.org/schema/mule/core":invoke, "http://www.mulesoft.org/schema/mule/core":abstract-global-intercepting-message-processor, "http://www.mulesoft.org/schema/mule/core":custom-queue-store, "http://www.mulesoft.org/schema/mule/core":abstract-processing-strategy}' is expected.
My mule flow is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<mule 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:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:core="http://www.mulesoft.org/schema/mule/core" version="CE-3.3.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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.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.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<context:component-scan base-package="com.comviva.mfs.eig.logging.dataAccess" />
<jms:activemq-connector name="Active_MQ" brokerURL="tcp://localhost:61616" validateConnections="true" doc:name="Active MQ"/>
I made sure that both xsi:schemaLocation and xmlns:context are declared.
Cannot figure out why sax parser exception is occurring.
Please Help me out.
Update:
Any Solution to Separate both the XML files will also work for me.
Please help me how to maintain separate ApplicationContext.xml for spring in our mule application.
I think you cannot use <context:component-scan> as a direct child of <mule>. Try the following:
<mule ...>
<spring:beans>
<context:component-scan ... />
</spring:beans>
</mule>
This is answer for the Update part of your question:
You can move <context:component-scan> alone to a new context file this way:
appnewcontext.xml:
<context:component-scan base-package="com.comviva.mfs.eig.logging.dataAccess" />
and import into the main one:
<beans:import resource="appnewcontext.xml"/>
You can ignore the resource is not defined error. That is a bug but doesn't impact your application from running.
Iam trying to send a string message from a java program to queue in ActiveMQ using MULE.Iam new to mule this is my mule-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jms="http://www.mulesoft.org/schema/mule/jms"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tool http://www.springframework.org/schema/tool/spring-tool-3.0.xsd
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/3.1/mule-jms.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.1/mule.xsd">
<jms:activemq-connector name="jmsConnector"
specification="1.1"
brokerURL="tcp://localhost:61616" />
<model name="jmsModel">
<service name="jmsService">
<inbound>
</inbound>
<outbound>
<pass-through-router>
<jms:outbound-endpoint queue="myQueue" />
</pass-through-router>
</outbound>
</service>
</model>
</mule>
and following is my java class
public class MuleCaller {
public static void main(String args[])
{
MuleCaller springCaller = new MuleCaller();
springCaller.runListner();
// spAsync.onMessage(null);
}
public void runListner(){
ClassPathXmlApplicationContext appContext = new ClassPathXmlApplicationContext(new String[] {
"mule-config.xml"
});
}
What are the mistakes here, and iam not clear what to be written in
Thanks and regards
This is based on an older Mule version (3.1.2) and is using flow syntax
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jms="http://www.mulesoft.org/schema/mule/jms"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.1/mule.xsd
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/3.1/mule-jms.xsd">
<jms:activemq-connector name="jmsConnector"
brokerURL="tcp://localhost:61616"
specification="1.1"
maxRedelivery="30"
disableTemporaryReplyToDestinations="true"
createMultipleTransactedReceivers="true"
acknowledgementMode="CLIENT_ACKNOWLEDGE"
numberOfConcurrentTransactedReceivers="1"
persistentDelivery="true">
</jms:activemq-connector>
<flow name="inbound JMS service">
<jms:inbound-endpoint connector-ref="jmsConnector" queue="/jmsQueue" exchange-pattern="one-way">
<jms:transaction action="BEGIN_OR_JOIN"/>
</jms:inbound-endpoint>
<echo-component/>
</flow>
Using the ActiveMQ console you can create a queue called jmsQueue and manually send messages to it. A Mule process using the config above should print out whatever text is in the message you place on the queue.
Firstly, there is a connector-ref attribute of the jms:outbound-endpoint tag that you should likely use to specific to where outbound messages are to go.
like this:
<jms:outbound-endpoint connector-ref="jmsConnection" queue="myQueue" />
Secondly, without an inbound route, i've no clue what data is to be operated on by your service. try to go through some more of the example.