Apache Camel cxfEndpoint - apache-camel

I'm trying to use WSRR (Websphere Service Registry and Repository) to retrieve the endpoint of the service that I'm consuming. I have a method which will lookup and return the endpoint of the service. I've set this to the publishedEndpointUrl in the properties.
But, it does not replace the value of the "address" and if I remove "address", it throws me an error. Is there another way to achieve this?
This is what I tried:
<cxf:cxfEndpoint id="test" address="https://..." serviceClass="...">
<cxf:properties>
<entry key="publishedEndpointUrl value="#{wsrr.getEndpoint()}">
</cxf:cxfEndpoint>
<cxf:cxfEndpoint>

Related

Camel CXF: Soap client timeout

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>

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.

Expose an OSGi Service as Camel Endpoint

I don't even know if I formulated the question the right way around ;-)
What I basically want to achieve is something like this:
<route >
<from uri="osgi:serviceName"/>
<!-- do some processing ->
<to uri="activemq:queue:inbox"/>
</route>
So I'd like to have an OSGi Service as starting point of my route. This service can be referenced by some other bundles and fed with input data, that will be later on processed by the Route.
How would I do this?
Simply create an OSGi service outside of camel and a route that starts with direct:anyname. Then you can inject a ProducerTemplate into your service an call the route from there.
If you have really simple method signature, or typeConverter for the parameters you want to pass, you can use CamelProxy to link the service to your route in a simple XML configuration file.
To extends the example of the doc, you would have something like :
<osgi:service id="service" ref="myProxySender" (4)
interface="org.apache.camel.spring.config.MyProxySender" />
<camelContext xmlns="http://camel.apache.org/schema/spring">
<!-- create a proxy that will route to the direct:start endpoint when invoked -->
<proxy id="myProxySender"
serviceInterface="org.apache.camel.spring.config.MyProxySender"
serviceUrl="direct:start"/>
<!-- this is the route that our proxy will routed when invoked
and the output from this route is returned as reply on the proxy -->
<route>
<from uri="direct:start"/>
<transform>
<simple>Bye ${body}</simple>
</transform>
</route>
</camelContext>
To use "osgi" as the URI scheme in a Camel route, you would need to create a custom Camel component to handle invoking the relevant OSGi commands. For more information, please see http://camel.apache.org/creating-a-new-camel-component.html
A simpler alternative would be to write custom OSGi commands that used a ProducerTemplate to send messages to a Camel route. An example for Karaf can be found here: https://github.com/apache/karaf/tree/master/demos/command
Injecting a ProducerTemplate can be done via standard Spring configuration.

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.

Resources