You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by jayasreeb <ja...@infosys.com> on 2008/07/10 15:06:40 UTC

Help!!! Urgent!!! Calling external web service from Fuse using HTTP

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 copied all these generated files to (src\main\java) folder and
created a client program as follows:

package org.apache.servicemix.samples.webservice;
import org.apache.servicemix.samples.fibonacci.*;



public class FibonacciClient{
  
 
 public static void main(String [] args) throws Exception {

   System.out.println("inside Finonacci Client Test");
   CalculateFibonacci cf = new CalculateFibonacci();
	cf. setIn0(3);
	System.out.println("Get Fibonacci--->"+cf.getIn0());
	CalculateFibonacciResponse response = new CalculateFibonacciResponse();
	response.getCalculateFibonacciReturn();

    }
}


9) Now I dont know how to test this client class whether its getting
response from external web service?

10) Do I need to create one more webservice internal to fuse to test it? If
so then what are the steps to test it?

10) Please help in resolving this as this is on high priority... please
suggest a solution for this...

Thanks
Jayasree.B
-- 
View this message in context: http://www.nabble.com/Help%21%21%21-Urgent%21%21%21-Calling-external-web-service-from-Fuse-using-HTTP-tp18382549p18382549.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.