-
1. Re: Call/consume an external webservice through JBoss Fuse ESB
ffang Dec 13, 2013 3:52 AM (in response to kunalsuri)1 of 1 people found this helpfulHi,
For your questions,
Thus, could you please help me by providing me some pointers on how to call or proxy any external service in JBoss Fuse.
Answer:
To use cxf proxy, camel-cxf should be the way to go, and ws-camel-proxy[1] is a good example.
Also, is there any possibility to get the some response time for this proxy this service using any available MBean like 'org.apache.cxf.management.counters.CounterRepository' so as to get an estimate of the difference between the request and response times.
Answer: no, the CounterRepository is server side mbean so can't be used from client proxy, you need get it from your cxf server deployed in tomcat(or whatever container)
ERROR] Plugin org.apache.cxf:cxf-codegen-plugin:2.6.0.redhat-60024 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org
.apache.cxf:cxf-codegen-plugin:jar:2.6.0.redhat-60024: Failure to find org.apache.cxf:cxf-codegen-plugin:pom:2.6.0.redhat-60024 in http://repo.fusesource.com/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of fusesource has elapsed or updates are forced -> [Help 1]
[ERROR]
Answer: sometimes clean the affected artifacts folder in your local maven repo may help.
[1]smx-ws-examples/ws-camel-proxy at master · FuseByExample/smx-ws-examples · GitHub
Freeman
-
2. Re: Call/consume an external webservice through JBoss Fuse ESB
kunalsuri Dec 13, 2013 1:59 PM (in response to ffang)Hi Freeman,
Thanks a lot for your answer
I fixed the [Error] plugin org.apache.cxf:cxf-codegen-plugin:2.6.0.redhat-60024... by adding a repository [1] in the main POM.XML as the problem was that the plugin was not being found in the repo's mentioned in the POM.XML file
Current Problem:
I tried to run and understand the 'smx-ws-examples' but it didn't help me much to create a camel proxy using external service. The example has the ws-camel-proxy which makes use of ws-camel-service internally and they both use the webservice created and exposed by the greeter.wsdl (again all in the ESB). It happens smoothy as all the code is generated internally and is installed into the ESB alltogether. Thus, when I test the example code it runs successfully.
But If I try to use my normal Cxf web service running external to the ESB (without any OSGi component) in a tomcat server and create the endpoint in the same way as mentioned in the example, it gives me errors.
My ws-camel-proxy.xml file looks like below:
where, the web-service http://localhost:9696/WSProxyTest/services/HelloWorldPort is running on an External Tomcat and the main class is 'com.xrce.monitoring.experiment.HelloWorld'
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camel="http://camel.apache.org/schema/spring"
xmlns:osgi="http://www.springframework.org/schema/osgi"
xmlns:cxf="http://camel.apache.org/schema/cxf"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf-2.8.3.xsd">
<!-- this is an camel cxf endpoint that takes its configuration from the interface generated by wsdl2java -->
<cxf:cxfEndpoint id="helloProxyXrce"
address="http://localhost:9069/helloProxyXRCE"
serviceClass="com.xrce.monitoring.experiment.HelloWorld"/>
<camelContext id="com.xrce.monitoring.experiment.ws-camel-proxy-xrce" xmlns="http://camel.apache.org/schema/spring">
<route id="proxy">
<from uri="cxf:bean:helloProxyXrce?dataFormat=POJO"/>
<convertBodyTo type="String"/>
<log message="SOAP proxy received : ${body} and operation type : ${in.header.SOAPAction}"/>
<!-- exposed by ws-cxf-service -->
<to uri="cxf:http://localhost:9696/WSProxyTest/services/HelloWorldPort?serviceClass=com.xrce.monitoring.experiment.HelloWorld" />
</route>
</camelContext>
</beans>
ERROR:
JBossFuse:karaf@root> features:install xrce-ws-proxy-examples
JBossFuse:karaf@root> Exception in thread "SpringOsgiExtenderThread-54" org.apahe.camel.RuntimeCamelException: org.apache.camel.FailedToCreateRouteException:failed to create route proxy: Route[[From[cxf:bean:helloProxyXrce?dataFormat=POJO]] ->
[Co... because of Failed to resolve endpoint: cxf://bean:helloProxyXrce?dataFormat=POJO due to: Cannot lookup: helloProxyXrce from registry: org.apache.camel.spring.spi.ApplicationContextRegistry@47a1c37b with expected type: class or
.apache.camel.component.cxf.
CxfEndpoint due: Error creating bean with name 'helloProxyXrce': Initialization of bean failed; nested exception is org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java lang.String' to required type 'java.lang.Class' for property 'serviceClass'; nested exception is java.lang.IllegalArgumentException: Cannot find class [com.xrce.monitoring.experiment.HelloWorld]
at org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1326)
I feel the main reason of the error is due to the fact that these classes are not installed/imported in the ESB. Because in the smx-ws-examples it has following osgi-export and import definations.
greeter-API has a osgi-export like
<properties>
<osgi-export-package>wsdl,com.fusesource.examples.greeter,com.fusesource.examples.greeter.model</osgi-export-package>
</properties>
WS-PARENT : pom.xml there is osgi-import
<properties>
<osgi-import-package>META-INF.cxf,com.xrce.monitoring.experiment.HelloWorld,*</osgi-import-package>
<osgi-dynamicimport-package>org.apache.cxf.*,org.springframework.beans.*</osgi-dynamicimport-package>
</properties>
Thus, the example it runs perfectly fine but I am not able to map this example to a case where I can run my external service successfully as a proxy.
Could you please provide me any other guidance points and/OR examples which would help to create my camel-proxy service.
Thanks again!
Kunal
[1] 'http://repo.fusesource.com/nexus/content/groups/public/'
-
3. Re: Call/consume an external webservice through JBoss Fuse ESB
kunalsuri Dec 16, 2013 8:03 AM (in response to kunalsuri)Hi,
I tried to understand and work out the proxy in the way explained in the example of smx-ws-examples but I am not able to perform the proxy as my webservice is running external to the Tomcat.
I tried to use the below method by using jetty and was bale to proxy my web services
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2012 FuseSource
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camel="http://camel.apache.org/schema/spring"
xmlns:osgi="http://www.springframework.org/schema/osgi"
xmlns:cxf="http://camel.apache.org/schema/cxf"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf-2.8.3.xsd">
<camelContext id="com.experiment.ws-camel-proxy-xrce" xmlns="http://camel.apache.org/schema/spring">
<route id="proxy">
<from uri="jetty:http://localhost:9069/helloProxyXRCE?matchOnUriPrefix=true"/>
<to uri="jetty:http://localhost:9696/WSProxyTest/services/HelloWorldPort?bridgeEndpoint=true&throwExceptionOnFailure=false"/>
</route>
</camelContext>
</beans>
In this process of creating a proxy, I can directly test http://localhost:9069/helloProxyXRCE?wsdl and it points to the external web service and runs successfully.
But, of-course I cannot see the name of the Proxy Service in my list for all the deployed CXF services as its not a CXF service rather just a simple proxy.
Thus, I would still like to ask for your guidance to understand the way in which I can use the 'cxfEndpoint' method to proxy and use the external service.
Thanks!
Kunal