You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by David M Nayagam <da...@wipro.com> on 2013/10/18 14:09:27 UTC
Getting error while consume the webservice using camel-cxf
Hi All,
i have created one sample web service and deployed in servicemix 4.5.2. i am
able to get the url and client java using getting response:
i am creating another project to consume the webservice but i am getting
error. Source and error is attached.
-----------------------------
ISimpleWebservice Interface
-----------------------------
package com.webservice.example;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
@WebService
public interface ISimpleWebservice
{
@WebResult(name="Customer")
public Customer getCustomer(@WebParam(name="cutomer") Customer
cutomer);
}
-------------------------------------
SimpleWebservice IMPL
-------------------------
package com.webservice.example;
import javax.jws.WebService;
@WebService(endpointInterface = "com.webservice.example.ISimpleWebservice",
serviceName = "ISimpleWebservice")
public class SimpleWebservice implements ISimpleWebservice
{
public Customer getCustomer(Customer cutomer)
{
System.out.println(" Calling IMPL Class......: "+
cutomer.getName());
cutomer.setDescription("SUCCESS");
return cutomer;
}
}
----------------------------
Customer POJO
--------------------
package com.webservice.example;
public class Customer
{
String name;
String description;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
-----------------------------
came-cxf.xml
-------------------
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:cxf="http://camel.apache.org/schema/cxf"
xmlns:soap="http://cxf.apache.org/bindings/soap"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd
http://camel.apache.org/schema/cxf
http://camel.apache.org/schema/cxf/camel-cxf.xsd
http://cxf.apache.org/bindings/soap
http://cxf.apache.org/schemas/configuration/soap.xsd">
<jaxws:endpoint id="aSimpleWebservice"
implementor="com.webservice.example.SimpleWebservice"
address="http://localhost:9003/weservice/SimpleWebservice">
</jaxws:endpoint>
</beans>
--------------------------------------
WSDL FILE
------------
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://example.webservice.com/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:ns1="http://schemas.xmlsoap.org/soap/http" name="ISimpleWebservice"
targetNamespace="http://example.webservice.com/">
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://example.webservice.com/"
attributeFormDefault="unqualified" elementFormDefault="unqualified"
targetNamespace="http://example.webservice.com/">
<xs:complexType name="getCustomer">
<xs:sequence>
<xs:element minOccurs="0" name="cutomer" type="tns:customer"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="customer">
<xs:sequence>
<xs:element minOccurs="0" name="description" type="xs:string"/>
<xs:element minOccurs="0" name="name" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="getCustomerResponse">
<xs:sequence>
<xs:element minOccurs="0" name="customer" type="tns:customer"/>
</xs:sequence>
</xs:complexType>
<xs:element name="getCustomer" nillable="true" type="tns:getCustomer"/>
<xs:element name="getCustomerResponse" nillable="true"
type="tns:getCustomerResponse"/>
</xs:schema>
</wsdl:types>
<wsdl:message name="getCustomer">
<wsdl:part element="tns:getCustomer" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getCustomerResponse">
<wsdl:part element="tns:getCustomerResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:portType name="ISimpleWebservice">
<wsdl:operation name="getCustomer">
<wsdl:input message="tns:getCustomer" name="getCustomer">
</wsdl:input>
<wsdl:output message="tns:getCustomerResponse"
name="getCustomerResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ISimpleWebserviceSoapBinding"
type="tns:ISimpleWebservice">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getCustomer">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="getCustomer">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getCustomerResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ISimpleWebservice">
<wsdl:port binding="tns:ISimpleWebserviceSoapBinding"
name="SimpleWebservicePort">
<soap:address
location="http://localhost:9003/weservice/SimpleWebservice"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
--------------------------------------------------------------------
==================
Consmer Projects:
==================
camel-context.xml
--------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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/context
http://www.springframework.org/schema/context/spring-context.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.xsd">
<bean id="enrich" class="com.enricher.Enrich" />
<cxf:cxfEndpoint id="SimpleWebservice"
address="http://localhost:9003/weservice/SimpleWebservice"
wsdlURL="http://localhost:9003/weservice/SimpleWebservice?wsdl"
endpointName="ISimpleWebservice"
serviceName="ISimpleWebservice"
serviceClass="com.webservice.example.ISimpleWebservice" />
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="file://D:/Input?noop=false"/>
<log message="Name of the client to be created received : "/>
<bean ref="enrich" method="createCustomer"/>
<log message="Enrich Crossed.....: "/>
<to uri="cxf:bean:SimpleWebservice"/>
<log message="SOAP Response received : ${body}"/>
<to uri="bean:enrich?method=createCustomer"/>
</route>
</camelContext>
</beans>
--------------------
ENRICH
-------------------
package com.enricher;
import org.apache.camel.Body;
public class Enrich
{
public Customer createCustomer(@Body Customer customer)
{
System.out.println("Comming to Enrich Method...");
Customer customer2 = new Customer();
customer2.setDescription("GOOD");
customer2.setName("ABC");
return customer2;
}
}
-----------------------------------
Customer
-----------
package com.enricher;
public class Customer
{
String name;
String description;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
---------------------------
But i am getting Error Like:
org.apache.camel.FailedToCreateProducerException: Failed to create Producer
for endpoint: Endpoint[cxf://bean:SimpleWebservice]. Reason:
org.apache.cxf.service.factory.ServiceConstructionException: Could not find
definition for service
{http://www.springframework.org/schema/beans}ISimpleWebservice.
at
org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:395)[101:org.apache.camel.camel-core:2.10.6]
at
org.apache.camel.impl.ProducerCache.acquireProducer(ProducerCache.java:114)[101:org.apache.camel.camel-core:2.10.6]
=====================================
Caused by: org.apache.cxf.service.factory.ServiceConstructionException:
Could not find definition for service
{http://www.springframework.org/schema/beans}ISimpleWebservice.
at
org.apache.cxf.wsdl11.WSDLServiceFactory.create(WSDLServiceFactory.java:171)[132:org.apache.cxf.cxf-rt-core:2.6.8]
at
org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromWSDL(ReflectionServiceFactoryBean.java:416)[132:org.apache.cxf.cxf-rt-core:2.6.8]
at
org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:538)[132:org.apache.cxf.cxf-rt-core:2.6.8]
*************************************************
Can you let me know what exactly I am doing wrong? I am new to Camel so
facing lot of issues.
I did lot of googling but not able to get it running. Is there any other
approach to consume the webservice.
Thanks in advance !!!!!
Thanks
David
9786495225
--
View this message in context: http://camel.465427.n5.nabble.com/Getting-error-while-consume-the-webservice-using-camel-cxf-tp5741833.html
Sent from the Camel - Users mailing list archive at Nabble.com.