Forum Home » Fuse Distributions » Fuse ESB

Thread: Urgent::How to write Client program in Fuse Calling external web service

 
This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 8 - Last Post: Jun 9, 2012 1:08 PM Last Post By: gertv
jayasreeb

Posts: 32
Registered: 03/31/08
Urgent::How to write Client program in Fuse Calling external web service
Posted: Jul 9, 2008 7:01 AM
 
  Click to reply to this thread Reply
Hi,

I have created a http webservice using axis (literal/wrapped) style and deployed it in Tomcat.
By entering "http://localhost:8080/axis/services/fibonacci?wsdl" in browser following wsdl gets generated.

<?xml version="1.0" encoding="UTF-8" ?>

  • <wsdl:definitions targetNamespace="urn:fibonacci" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="urn:fibonacci" xmlns:intf="urn:fibonacci" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  • <!--
WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)

-->
<wsdl:types>
<schema elementFormDefault="qualified" targetNamespace="urn:fibonacci" xmlns="http://www.w3.org/2001/XMLSchema">
<element name="calculateFibonacci">
<complexType>
<sequence>
<element name="in0" type="xsd:int" />
</sequence>
</complexType>
</element>
<element name="calculateFibonacciResponse">
<complexType>
<sequence>
<element name="calculateFibonacciReturn" type="xsd:int" />
</sequence>
</complexType>
</element>
<element name="calculateFibonacciRange">
<complexType>
<sequence>
<element name="in0" type="xsd:int" />
<element name="in1" type="xsd:int" />
</sequence>
</complexType>
</element>
<element name="calculateFibonacciRangeResponse">
<complexType>
<sequence>
<element maxOccurs="unbounded" name="calculateFibonacciRangeReturn" type="xsd:int" />
</sequence>
</complexType>
</element>
</schema>
</wsdl:types>
<wsdl:message name="calculateFibonacciRangeResponse">
<wsdl:part element="impl:calculateFibonacciRangeResponse" name="parameters" />
</wsdl:message>
<wsdl:message name="calculateFibonacciRequest">
<wsdl:part element="impl:calculateFibonacci" name="parameters" />
</wsdl:message>
<wsdl:message name="calculateFibonacciRangeRequest">
<wsdl:part element="impl:calculateFibonacciRange" name="parameters" />
</wsdl:message>
<wsdl:message name="calculateFibonacciResponse">
<wsdl:part element="impl:calculateFibonacciResponse" name="parameters" />
</wsdl:message>
<wsdl:portType name="Fibonacci">
<wsdl:operation name="calculateFibonacci">
<wsdl:input message="impl:calculateFibonacciRequest" name="calculateFibonacciRequest" />
<wsdl:output message="impl:calculateFibonacciResponse" name="calculateFibonacciResponse" />
</wsdl:operation>
<wsdl:operation name="calculateFibonacciRange">
<wsdl:input message="impl:calculateFibonacciRangeRequest" name="calculateFibonacciRangeRequest" />
<wsdl:output message="impl:calculateFibonacciRangeResponse" name="calculateFibonacciRangeResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="fibonacciSoapBinding" type="impl:Fibonacci">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="calculateFibonacci">
<wsdlsoap:operation soapAction="" />
<wsdl:input name="calculateFibonacciRequest">
<wsdlsoap:body use="literal" />
</wsdl:input>
<wsdl:output name="calculateFibonacciResponse">
<wsdlsoap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="calculateFibonacciRange">
<wsdlsoap:operation soapAction="" />
<wsdl:input name="calculateFibonacciRangeRequest">
<wsdlsoap:body use="literal" />
</wsdl:input>
<wsdl:output name="calculateFibonacciRangeResponse">
<wsdlsoap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="FibonacciService">
<wsdl:port binding="impl:fibonacciSoapBinding" name="fibonacci">
<wsdlsoap:address location="http://localhost:8080/axis/services/fibonacci" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

1)I created service unit and I have placed this wsdl file(fib.wsdl) in(src\main\resources) of service unit(cxf-se).

2)I have added following entry in xbean of service unit(cxf-se):

<beans xmlns:cxfse="http://servicemix.apache.org/cxfse/1.0">

<cxfse:endpoint>
<cxfse:pojo>
<bean class="org.apache.servicemix.samples.webservice.FibonacciClient">
</bean>
</cxfse:pojo>
</cxfse:endpoint>

</beans>

3)I have added following entry in pom.xml file of service unit(cxf-se) to generate xfire client stub during run time.


<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>generate-sources</phase>
<configuration>
<tasks>
<taskdef classname="org.codehaus.xfire.gen.WsGenTask" name="wsgen" classpathref="maven.compile.classpath">
</taskdef>

<wsgen
wsdl="${basedir}/src/main/resources/fib.wsdl"
outputDirectory="${basedir}/target/generated-sources"
profile="org.codehaus.xfire.jaxws.gen.JAXWSProfile"
explicitAnnotation="true" />
</tasks>
<sourceRoot>
${basedir}/target/generated-sources
</sourceRoot>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>

4)I also created one binding component Service unit(cxf-bc) and placed the same wsdl file (fib.wsdl)under(src\main\resources).

5)I have added following xbean entry in Binding component xbean::

<cxfbc:provider wsdl="/wsdl/fib.wsdl" locationURI="http://localhost:8080/axis/services/fibonacci" service="fib:FibonacciService" endpoint="FibonacciClient" interfaceName="fib:Fibonacci" > </cxfbc:provider>

6)When I give mvn install all the neccessary jar and class file gets generated properly.

7)Following Client stubs class file gets generated under(target\classess\fibonacci) folder of cxf-se service unit.

i)CalculateFibonacci.java
ii)CalculateFibonacciRange.java
iii)CalculateFibonacciRangeResponse.java
iv)CalculateFibonacciResponse.java
v)Fibonacci.java
vi)FibonacciServiceImpl.java
vii)FibonacciServiceService.java
vIII)ObjectFactory.java

8) Now I dont know how to write client class to invoke that external webservice which is running on tomcat server deployed using axis.

9)Where do I need to place Client Class which I need to use to Invoke this exgternal web service?Will it work if i place it under (src\main\java) of cxf-se service unit?

10) Which of the following generated class do i need to use to invoke the method of external web service?

11) Do i need to make any additional entry in xbean/pom files?

Please help me in this as this is on high priority..

Thanks
Jayasree.B

edelln

Posts: 44
Registered: 01/17/08
Re: Urgent::How to write Client program in Fuse Calling external web service
Posted: Jul 9, 2008 8:04 AM   in response to: jayasreeb in response to: jayasreeb
 
  Click to reply to this thread Reply
Hi,

Whats the purpose of your org.apache.servicemix.samples.webservice.FibonacciClient
class - what is it currently doing. You could just make the call from there to the external web service.

Edell.
jayasreeb

Posts: 32
Registered: 03/31/08
Re: Urgent::How to write Client program in Fuse Calling external web service
Posted: Jul 9, 2008 9:40 AM   in response to: jayasreeb in response to: jayasreeb
 
  Click to reply to this thread Reply
Hi

I need to call and get response from method calculatefibonacci defined in external webservice from my client program written in FUSE.
Pls suggest me how to write client program in FUSE?
sracem

Posts: 11
Registered: 04/27/12
Re: Urgent::How to write Client program in Fuse Calling external web service
Posted: Jun 1, 2012 8:28 AM   in response to: jayasreeb in response to: jayasreeb
 
  Click to reply to this thread Reply
Hi Jay,

In fact i need also to call and get responce from method defined in external webservice, are you resolved your problem?
ffang

Posts: 1,320
Registered: 12/24/07
Re: Urgent::How to write Client program in Fuse Calling external web service
Posted: Jun 1, 2012 9:07 AM   in response to: sracem in response to: sracem
 
  Click to reply to this thread Reply
Hi,

You replied a very old thread which is almost 4 years ago.
The JBI way suggested here is kinda deprecated, you should use camel component instead if you start with a new project.
You can use camel-cxf to invoke external webservice and process response message.
Take a look at
http://camel.apache.org/cxf.html
to get more details
Freeman
sracem

Posts: 11
Registered: 04/27/12
Re: Urgent::How to write Client program in Fuse Calling external web service
Posted: Jun 6, 2012 9:39 AM   in response to: ffang in response to: ffang
 
  Click to reply to this thread Reply
Hi,

i decided to change JBI omponents :)
so before to start i want to know what is better: use camel components or osgi buindles and why?

thanks
ffang

Posts: 1,320
Registered: 12/24/07
Re: Urgent::How to write Client program in Fuse Calling external web service
Posted: Jun 6, 2012 12:38 PM   in response to: sracem in response to: sracem
 
  Click to reply to this thread Reply
Hi,

Actually all camel components are already bundles, and if you write your own camel routers, they should be bundle as well. So it's not you need make a choice between camel components and bundles, they already bind together and works in OSGi container.

Freeman
sracem

Posts: 11
Registered: 04/27/12
Re: Urgent::How to write Client program in Fuse Calling external web service
Posted: Jun 7, 2012 9:03 AM   in response to: ffang in response to: ffang
 
  Click to reply to this thread Reply
Hi,

thanks for your responses

if i good understand, when i want to create new camel component, i create new maven module with servicemix-camel-osgi-bundle as archetype, then i add dependecy to the camel component. it is true this?

in fact i search example that contains different components, in my case i need three components : component recover message from external webservice, component that send message to external webservice and another component to route messages from the first component to the second.
gertv

Posts: 167
Registered: 06/18/08
Re: Urgent::How to write Client program in Fuse Calling external web service
Posted: Jun 9, 2012 1:08 PM   in response to: sracem in response to: sracem
 
  Click to reply to this thread Reply
L.S.,

You should be able to handle this scenario with the camel-cxf endpoints. Camel already provides the routing you require out of the box, so all you need to do is to create a route that start and ends with a camel-cxf endpoint.

Regards,

Gert Vanthienen