Camel CXF: Soap client timeout - apache-camel

I am using Camel CXF endpoint to connect to my soap server. I wanted to add timeout for my request from client. I am using continuationTimeout option for that. But it's not working. The request is timeout without waiting for the time that I've configured.
Below is my endpoint configuration.
<camel-cxf:cxfEndpoint id="tmAPIWSEndpoint" address="http://IN2NPDCEDB01:8088/webservices/services/TransportationManager"
wsdlURL="/wsdl/TransportationManager.wsdl"
endpointName="cis:TransportationManagerPort"
serviceName="cis:TransportationManagerService"
xmlns:cis="http://www.i2.com/cis"
continuationTimeout="60000">
<camel-cxf:properties>
<entry key="dataFormat" value="MESSAGE"/>
<entry key="username" value="XXX"/>
<entry key="password" value="XXX"/>
</camel-cxf:properties>
</camel-cxf:cxfEndpoint>

Your question is not very clear since there is no camel route so I cant see if you are creating a SOAP service inside Camel or you are calling a SOAP service from Camel as the client. Based on the little bit information you sent it seems you are creating a client.
According to the camel CXF documentation
continuationTimeout: This option is used to set the CXF continuation timeout which could be used in CxfConsumer by default
when the CXF server is using Jetty or Servlet transport. (Before
Camel 2.14.0, CxfConsumer just set the continuation timeout to be
0, which means the continuation suspend operation never timeout.)
Notice that this is related to CXF server settings not client settings. You are using this property but I dont think this is what you are looking for.
If you reference the Apache CXF Client Settings Documentation page you will find the following notes there:
ConnectionTimeout: Specifies the amount of time, in milliseconds, that the client will attempt to establish a connection before it
times out. The default is 30000 (30 seconds). 0 specifies that the
client will continue to attempt to open a connection indefinitely.
ReceiveTimeout: Specifies the amount of time, in milliseconds, that the client will wait for a response before it times out. The
default is 60000. 0 specifies that the client will wait indefinitely.
If you visit the CXF documentation page there is a lot examples there.

Here is how to do it programmatically:
HelloWorld hello = (HelloWorld) context.getBean("helloService");
org.apache.cxf.endpoint.Client client = ClientProxy.getClient(hello);
HTTPConduit httpConduit = (HTTPConduit) client.getConduit();
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setConnectionTimeout(5000);
httpClientPolicy.setAllowChunking(false);
httpClientPolicy.setReceiveTimeout(5000);
httpConduit.setClient(httpClientPolicy);
System.out.println(hello.getHelloWorldAsString("Everyone"));
(I am using spirng)
<bean id="helloService"
class="soap.timeout.demo.client.jaxws.HelloWorld"
factory-bean="helloServiceFactory" factory-method="create"/>
<bean id="helloServiceFactory"
class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
<property name="serviceClass" value="soap.timeout.demo.client.jaxws.HelloWorld"/>
<property name="address" value="http://localhost:9999/ws/hello"/>
</bean>

Related

Produce messages to IBM MQ using REST API. Apache Camel

I have to send messages to IBM MQ by hitting a rest service. Below is the code I came up with, using Camel XML DSL.
<rest path="/basePath">
<post uri="/path" consumes="application/xml" produces="application/xml">
<to uri="ibmmq:QUEUE.NAME"/>
</post>
</rest>
When I try to post the message, I get the following exception
org.apache.camel.RuntimeExchangeException: Failed to resolve replyTo destination on the exchange
Is the post method expecting response back from QUEUE, so that it can respond back to rest client?
I only need the post service to reply with 200, if the message is successfully produced to QUEUE, 500 otherwise.
How to solve this problem?
Pattern of your exchange is InOut so this is default behavior for your jms producer. Try change it for specific endpoint like this:
<to uri="ibmmq:QUEUE.NAME" pattern="InOnly"/>

httpClientConfigurerRef for Apache Camel for specific routes

Lets say that I want to communicate to a rest service with SSL with Camel, and I'm creating a custom HttpClientConfigurer which will set that stuff:
<bean id="myHttpClientConfigurer"
class="my.https.HttpClientConfigurer">
</bean>
<to uri="https://myhostname.com:443/myURL?httpClientConfigurerRef=myHttpClientConfigurer"/>
And the HttpClientConfigurer implements org.apache.camel.component.http.HttpClientConfigurer.
So my question is, will this custom HttpClientConfigurer will be active for only that route (where I specify it with httpClientConfigurerRef)? Or will it affect other Camel routes that use the http component?
Just for that route. Always test and verify! Fire up a second route without it and you should observe that the second route does not handle the SSL handshake.

parameters in WSO2 API manager

I am creating an API with URI template patient/{name} and production URL to http://localhost:8888/patient/{uri.var.name} in WSO2 APIM. Also adding this sequence
<sequence xmlns="http://ws.apache.org/ns/synapse" name="TestSequence">
<property name="REST_URL_POSTFIX" scope="axis2" action="remove"/>
</sequence>
The target URL is not being invoked with this. Can you please let me know what is the issue?
This error can occur due to Invalid URI provided by you, make sure you are using valid endpoint url for the Production Endpoint.

Create proxy for Apache CXF Web services in wso2 ESB

I am a very beginner in ESB. So, kindly excuse me for this basic question.
Currently we have web services created with Apache CXF and Spring running. Now, we need to create proxy services for these in WSo2 ESB. Can someone please let us know how can we do this?
I created Pass Through proxy and use wsdl definition as from URL, but when i use try it option i get he endpoint reference (EPR) for the Operation not found is /services/ and the WSA Action = null.
If this EPR was previously reachable,please contact the server administrator.
Since ESB 4.6, pass-through transport is enabled by default : The message body is not build so, SOAP Body based dispatching is not supported => in this case, the error you're speaking about is thrown
One solution could be to add this parameter in your proxy conf : <parameter name="disableOperationValidation" locked="false">true</parameter>
Have a look there for other options : Using WSO2 ESB PassThrough Proxy on WebLogic (Spring) Web Service
How did you create the proxy service? If you have the wsdl of the Backend service you can use it to create the proxy service like follows.
<proxy xmlns="http://ws.apache.org/ns/synapse" name="testProxy2" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<outSequence>
<send/>
</outSequence>
<endpoint>
<wsdl service="SimpleStockQuoteService"
port="SimpleStockQuoteServiceHttpSoap11Endpoint"
uri="http://localhost:9000/services/SimpleStockQuoteService?wsdl"/>
</endpoint>
</target>
<description/>
</proxy>
The ESB gets the endpoint url from the Service name and Port defined in the WSDL. For SOAP 1.1 the WSA action will be the SOAPAction header and for SOAP 1.2 the WSA action goes with the action element of Content-Type header. For example,
Content-Type: application/soap+xml;charset=UTF-8;action="TheSoapAction"
Try to use a SOAP client like SOAPUI to test your proxy service.

Camel CXF consumer, webservice method has no response

I'm trying to consume a webservice from camel using the cxf component, like this:
<cxf:cxfEndpoint id="webservice"
address="http://webservice.url.com/webservice"
serviceClass="com.url.webservice.MyWebService"/>
<camel:camelContext>
<camel:route>
<camel:from uri="direct:a"/>
<camel:inOnly uri="cxf:bean:webservice?defaultOperationName=sendMessage"/>
</camel:route>
</camel:camelContext>
The sendMessage method has no response, hence the inOnly rather than to (although I have the same problem when I try to instead). The problem is that apparently camel still expects a response, and the route hangs while waiting for one. I suppose if I let it try long enough, it would eventually time out.
To be clear, I'm running a test method:
/* ... */
#Produce(uri = "direct:a")
protected ProducerTemplate directA;
#Test
public void sendMessage() throws Exception {
directA.sendBody(new String[] {"client id", "message"});
directB.sendBody(new String[] {"client id", "message 2"});
}
And I'm seeing the effect of the first call (that is, the message arrives at the server), but not the second, and the method doesn't finish running (again, I'm assuming it'll timeout at some point... if so, the timeout's pretty long: I ran the test as I started writing this, and it's still running).
Am I missing something? Is it a bug? Is it just bad practice to have webservice methods with no response?
By the way, when testing methods which have a response, it works fine.
I think Willem Jiang recently fixed some issue with one-way CXF in Camel recently. Maybe try Camel 2.6-SNAPSHOT from trunk.
I personally prefer two-way with web services, just returning some ACK back in case there is no data to return back. The client most often want some confirmation the server has received and acknowledged the data.
camel-cxf producer decides if it will handle the response message by checking if the operation is oneway. Even the sendMessage operation is oneway invocation, your server should send Http states 202 message to the client according the HTTP protocol, otherwise camel-cxf producer will still wait for the response.
BTW, I think the issue[1] that Claus said was related to async invocation of camel-cxf producer with one way message, not sure if it's the same issue as you mentioned(I didn't know which version of camel are you using).
[1]https://issues.apache.org/jira/browse/CAMEL-3426
Willem

Resources