I have an http:inbound-endpoint. Is there any way to get a handle to HttpServletRequest object in a Filter/Interceptor? Is ObjectToHttpClientMethodRequest an answer? If so, could someone please provide a sample?
If you are running Mule in a servlet container, you need to use servlet:inbound-endpoint, not http:inbound-endpoint.
But even with that, I do not think Mule lets you access the underlying HttpServletRequest...
Related
I'm using WS Consumer component to call an external Web Servcie and
I'm looking for a way to prevent generation of a SOAP header in the request.
I've found how to do this when using cxf component explicitly:
<cxf:configuration enableMuleSoapHeaders="false"/>
and then same in <cxf:jaxws-client ...
But I can't figure out how to achieve the same when using WS Consumer.
So, can someone pls advice?
Thank you,
Ok, I've found the answer by myself.
Basically, WS Consumer (v3.7) doesn't have an attribute similar to the enableMuleSoapHeaders from the cxf component.
So, you'll need to code the logic in java.
First, you need to code your own CXF interceptor that would go through the message and remove the unnecessary headers.
Then, you need to create a cxf configuration file (the default name is cxf.xml) and put it into the mule project classpath.
Once this is done, Mule will call the interceptor for every cxf message processed and remove the headers.
For more info about coding and configuring cxf interceptor look at the apache documentation here.
Good day,
We have the requirement to call a MobileFirst Adapter via curl and SOAP, ommiting authentication.
An example how to do it with curl and application/x-www-form-urlencoded looks like this, but we also require to invoke the adapter using SOAP.
curl -XPOST -d 'adapter=PushAdapter&procedure=sendNotifications¶meters=["[\"UserA\",\"UserB\"]", "Pushed.you"]' http://localhost:10080/application/invoke
The reason is, we want to trigger sending PushNotifications through a network zone that only allows SOAP.
We are open to different suggestions, like implementing a new JavaAdapter (not JS), implementing an extra WebService, or anything that pops up which could fulfil the requirement in an acceptable way.
I hope someone can come up with an idea how to call Adapters via SOAP, ommiting authentication.
Thank you,
gizmore
---- Edit ---
I added a new Java Adapter, like the video from Hasan suggests.
Thank you very much for that hint :)
There i added a WebService like this:
#WebService
#Path("/soap")
#OAuthSecurity(enabled=false) // Disable the imfAuthentication :)
public class ExternalPushService {
#POST
#Path("/push")
#WebMethod(action="push")
public String push(#WebParam(name="name") String name) {
return name + "ABC";
}
}
I can now do HTTP POST Requests to the http://localhost:10080/app/adapters/PushBridge/soap/push Endpoint, but the SOAP is not parsed.
Instead i get the complete Envelope in the "name" parameter.
If i do a SOAP call to PushBridge/soap, i get 405 Method not allowed.
Does someone have an idea, how i can get SOAP working out of the box there?
Answer is: NO
when you adding #WebService in your java adapter this the warring facing:
Problem description:This annotation requires a web service project. Convert the Java project to a web project targeting the specified runtime environment
SOAP base service are based on the JAX-WS specification.
but
Java adapters are based on the JAX-RS specification.
https://developer.ibm.com/mobilefirstplatform/documentation/getting-started-7-0/server-side-development/java-adapter/
Let me explain my configuration:
ActiveMQ 5.12.0
AnyPoint Studio 5.2.1
Mule 3.6.1
Flow of application:
I am using FunctionalTestCase to post and retrieve a message from queue.
MuleClient client = muleContext.getClient();
String productAsJson = "{\"name\":\"Widget\", \"price\":9.99, \"weight\":1.0, \"sku\":\"abcd-12345\"}";
client.dispatch("http://localhost:8081/products", productAsJson, null);
MuleMessage result = client.request("jms://products", RECEIVE_TIMEOUT);
What is happening is the message is getting posted but when I try to retrieve it, I get the string "{NullPayLoad}".
After stepping back through the flow, I have discovered the message payload, when using the Mule Client, is not making the queue. While looking through the admin console for ActiveMQ, I discovered the message details is "{NullPayload}". When I check using the Advance Risk Client, the JSON message is getting posted correctly.
Any suggestions would be greatly appreciated.
Russ
It's NullPayload when using the MuleClient because by default the http operation will be GET and wont be expecting a body to parse.
The MuleClient is more suited to working with Mule transport infrastructure such as the JMS transport or the old http transport. I don't think it plays nice with the new http listener module.
Normally with the transports you can set the method via a property but that doesnt seem to work with the http:listener:
MuleMessage message = getTestMuleMessage();
message.setPayload(productAsJson);
message.setProperty("http.method", "POST", PropertyScope.INBOUND);
client.send("http://localhost:8089/products", message);
I would suggest using a standard HTTP client such as Apache HTTP client etc. and set the method to POST/PUT or whatever method you need to use that expects a body.
I am working on a mule studio application in which I am calling a soap web service for getting status of a particular process. If the status is PENDING, I have to call the same web service until the status become COMPLETED. What approach I have to take for implementing this scenario.
Thank You in advance.
Take a look at the until-successful router: http://www.mulesoft.org/documentation/display/current/Until+Successful+Scope
You can configure the failureExpression to check if the status is 'PENDING'.
As Ryan Carter said, you can use the Until Successful router in order to achieve this.
You need to configure the failureExpression attribute to return 'true' if you want to call the web service again.
Note also that you can configure the until successful to be "synchronous" instead of the default "asynchronous". The former configuration does not require an object store.
I've gone through AnyPoint Connector tutorial of mulesoft. Here Following this tutorial I was able to get response in logger in mule studio console. Then I thought to to one step further, to create a web application and get response back to my application html file. In this way I am getting response as a file which is of type Application/octate-stream But I want a json response.
I have no idea to do this. Please tell me the way. I am very new to mule and web services stuff. In fact I started my study on mule two days back only.
Thanks.
Select "Object to JSON" from Mule toolbar "Transformers" list, and add that as the last component inside the flow.