You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by jiangfan <17...@qq.com> on 2011/12/29 09:16:44 UTC

CXF -- problem how to use Camel-Cxf to invoke a webservice

Hi,
I used to do, to write a bean, then use the bean webservice to call .
like this: 
            <camel:camelContext autoStartup="true" trace="true">
		<camel:route id="old-example">
			<camel:from uri="jms:queue:old-example?jmsMessageType=Text" />
			<camel:to uri="bean:serviceOldInvokerBean?method=invokerSomeService" />
		</camel:route>

	</camel:camelContext>
	<bean id="serviceOldInvokerBean"
class="com.ygsoft.cxfExample.bean.ServiceOldInvokerBean" />

Now I want to use a camel-CXF component to call webservice 

can you show me a example ?


Thanks in advance, 
Jiangfan

--
View this message in context: http://camel.465427.n5.nabble.com/CXF-problem-how-to-use-Camel-Cxf-to-invoke-a-webservice-tp5107111p5107111.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: CXF -- problem how to use Camel-Cxf to invoke a webservice

Posted by jiangfan <17...@qq.com>.
Willem thank you for your advice!

Now I to go so call, but will make an exception, don't know is written
routing problem, or bean processing 

this is my route:
<camel:route id="cxf-example">
    <camel:from uri="jms:queue:cxf-example?jmsMessageType=Text" />
    <camel:to uri ="bean:serviceCXFInvokerBean?method=process" />
    <camel:to
uri="cxf://http://127.0.0.1:8080/YGFMISWeb/services/BlfThirdIntegrate?serviceClass=com.ygsoft.cxfExample.ws.BlfThirdIntegrate"
/>
    <log loggingLevel="INFO" message="&gt;&gt;&gt;${body}" />
</camel:route>

and the serviceCXFInvokerBean:

public class ServiceCXFInvokerBean {
	private static final Log log =
LogFactory.getLog(ServiceCXFInvokerBean.class);
	private String grisWebServiceURL =
"http://127.0.0.1:8080/YGFMISWeb/services/BlfThirdIntegrate";

	public void process(Exchange exchange) {
		final List<String> params = new ArrayList<String>();
		log.info("Enter ServiceCXFInvokerBean ");
		params.add("===123456===");
		// Set the request context to the inMessage
		Map<String, Object> requestContext = new HashMap<String, Object>();
	
requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,grisWebServiceURL);
		exchange.getIn().setBody(params);
		exchange.getIn().setHeader(Client.REQUEST_CONTEXT, requestContext);
		exchange.getIn().setHeader(CxfConstants.OPERATION_NAME, "getZWItemsYW");
		exchange.getOut();
	}
}

I have some doubts, I hope you can help me
1.When I perform procedures, backstage displays RuntimeCamelException:
org.apache.camel.RuntimeCamelException:
org.apache.cxf.binding.soap.SoapFault: Fault occurred while processing.
	at
org.apache.camel.util.ObjectHelper.wrapRuntimeCamelException(ObjectHelper.java:1039)
	at
org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:103)
....
....
Caused by: org.apache.cxf.binding.soap.SoapFault: Fault occurred while
processing.
	at
org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.unmarshalFault(Soap11FaultInInterceptor.java:75)
...
...

2.It is my intention to call the service, but I saw the background that
shows the create service:

2011-12-30 17:16:29
org.apache.cxf.service.factory.ReflectionServiceFactoryBean
buildServiceFromClass
info: Creating Service
{http://ws.cxfExample.ygsoft.com/}BlfThirdIntegrateService from class
com.ygsoft.cxfExample.ws.BlfThirdIntegrate


Thanks in advance, 
Fan Jiang

--
View this message in context: http://camel.465427.n5.nabble.com/CXF-problem-how-to-use-Camel-Cxf-to-invoke-a-webservice-tp5107111p5109719.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: CXF -- problem how to use Camel-Cxf to invoke a webservice

Posted by Willem Jiang <wi...@gmail.com>.
Hi,

I think you should use the POJO data format which save you lots of time 
to prepare the request and parser the response.
If you are using MESSAGE data format, you need to create the soap 
message yourself.

BTW, the WSDL is using document-literal, CXF support it out of box.

On Fri Dec 30 11:45:13 2011, jiangfan wrote:
> I now is to want to use the Camel-CXF call to the third party web services.
> They provide to me they released WSDL documents :
>
>   <?xml version="1.0" encoding="UTF-8" ?>
> -<wsdl:definitions name="BlfThirdIntegrateImplService"
> targetNamespace="http://ws.cxfExample.ygsoft.com/"
> xmlns:ns1="http://cxf.apache.org/bindings/xformat"
> xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
> xmlns:tns="http://ws.cxfExample.ygsoft.com/"
> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema">
> -<wsdl:types>
> +<xsd:schema attributeFormDefault="unqualified"
> elementFormDefault="unqualified"
> targetNamespace="http://ws.cxfExample.ygsoft.com/"
> xmlns:tns="http://ws.cxfExample.ygsoft.com/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema">
>    <xsd:element name="getZWItemsYW" type="tns:getZWItemsYW" />
> +<xsd:complexType name="getZWItemsYW">
>    <xsd:sequence />
>    </xsd:complexType>
>    <xsd:element name="getZWItemsYWResponse" type="tns:getZWItemsYWResponse"
> />
> +<xsd:complexType name="getZWItemsYWResponse">
> -<xsd:sequence>
>    <xsd:element minOccurs="0" name="return" type="xsd:string" />
>    </xsd:sequence>
>    </xsd:complexType>
>    <xsd:element name="newQueryZWData" type="tns:newQueryZWData" />
> +<xsd:complexType name="newQueryZWData">
> -<xsd:sequence>
>    <xsd:element minOccurs="0" name="arg0" type="xsd:string" />
>    <xsd:element minOccurs="0" name="arg1" type="xsd:string" />
>    <xsd:element name="arg2" type="xsd:int" />
>    <xsd:element minOccurs="0" name="arg3" type="xsd:string" />
>    </xsd:sequence>
>    </xsd:complexType>
>    <xsd:element name="newQueryZWDataResponse"
> type="tns:newQueryZWDataResponse" />
> +<xsd:complexType name="newQueryZWDataResponse">
> -<xsd:sequence>
>    <xsd:element minOccurs="0" name="return" type="xsd:string" />
>    </xsd:sequence>
>    </xsd:complexType>
>    </xsd:schema>
>    </wsdl:types>
> +<wsdl:message name="newQueryZWData">
>    <wsdl:part element="tns:newQueryZWData" name="parameters" />
>    </wsdl:message>
> +<wsdl:message name="newQueryZWDataResponse">
>    <wsdl:part element="tns:newQueryZWDataResponse" name="parameters" />
>    </wsdl:message>
> -<wsdl:message name="getZWItemsYW">
>    <wsdl:part element="tns:getZWItemsYW" name="parameters" />
>    </wsdl:message>
> -<wsdl:message name="getZWItemsYWResponse">
>    <wsdl:part element="tns:getZWItemsYWResponse" name="parameters" />
>    </wsdl:message>
> -<wsdl:portType name="BlfThirdIntegrate">
> -<wsdl:operation name="getZWItemsYW">
>    <wsdl:input message="tns:getZWItemsYW" name="getZWItemsYW" />
>    <wsdl:output message="tns:getZWItemsYWResponse"
> name="getZWItemsYWResponse" />
>    </wsdl:operation>
> +<wsdl:operation name="newQueryZWData">
>    <wsdl:input message="tns:newQueryZWData" name="newQueryZWData" />
>    <wsdl:output message="tns:newQueryZWDataResponse"
> name="newQueryZWDataResponse" />
>    </wsdl:operation>
>    </wsdl:portType>
> -<wsdl:binding name="BlfThirdIntegrateImplServiceSoapBinding"
> type="tns:BlfThirdIntegrate">
>    <soap:binding style="document"
> transport="http://schemas.xmlsoap.org/soap/http" />
> -<wsdl:operation name="getZWItemsYW">
>    <soap:operation soapAction="" style="document" />
> -<wsdl:input name="getZWItemsYW">
>    <soap:body use="literal" />
>    </wsdl:input>
> -<wsdl:output name="getZWItemsYWResponse">
>    <soap:body use="literal" />
>    </wsdl:output>
>    </wsdl:operation>
> +<wsdl:operation name="newQueryZWData">
>    <soap:operation soapAction="" style="document" />
> -<wsdl:input name="newQueryZWData">
>    <soap:body use="literal" />
>    </wsdl:input>
> -<wsdl:output name="newQueryZWDataResponse">
>    <soap:body use="literal" />
>    </wsdl:output>
>    </wsdl:operation>
>    </wsdl:binding>
> -<wsdl:service name="BlfThirdIntegrateImplService">
> -<wsdl:port binding="tns:BlfThirdIntegrateImplServiceSoapBinding"
> name="BlfThirdIntegrateImplPort">
>    <soap:address
> location="http://127.0.0.1:8080/YGFMISWeb/services/BlfThirdIntegrate" />
>    </wsdl:port>
>    </wsdl:service>
>    </wsdl:definitions>
>
>
> Now I want to call the service of the method is getZWItemsYW
> My camel routing is like this :
> <camel:route id="cxf-example">
>      <camel:from uri="jms:queue:cxf-example?jmsMessageType=Text" />
>      <camel:to
> uri="cxf://http://127.0.0.1:8080/YGFMISWeb/services/BlfThirdIntegrate?wsdl?wsdlURL=src/main/resources/BlfThirdIntegrate.wsdl&amp;serviceName={http://ws.cxfExample.ygsoft.com/}BlfThirdIntegrateImplService&amp;portName={http://ws.cxfExample.ygsoft.com/}BlfThirdIntegrateImplPort&amp;dataFormat=MESSAGE"
> />
>      <camel:log loggingLevel="INFO" message="&gt;&gt;&gt;${body}" />
> </camel:route>
>
> I have some questions:
> 1.Write like this, can I call for example Axis released service
> 2.One of the local written, I guess is basic it is, don't know the correct
> this how to write:
> <camel:to
> uri="cxf://http://127.0.0.1:8080/YGFMISWeb/services/BlfThirdIntegrate?wsdl?wsdlURL=src/main/resources/BlfThirdIntegrate.wsdl&amp;serviceName={http://ws.cxfExample.ygsoft.com/}BlfThirdIntegrateImplService&amp;portName={http://ws.cxfExample.ygsoft.com/}BlfThirdIntegrateImplPort&amp;dataFormat=MESSAGE"
> />
> Because to finish this section of time I found that didn't write operation
> in
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/CXF-problem-how-to-use-Camel-Cxf-to-invoke-a-webservice-tp5107111p5109194.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>


-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
          http://jnn.javaeye.com (Chinese)
Twitter: willemjiang
Weibo: willemjiang

Re: CXF -- problem how to use Camel-Cxf to invoke a webservice

Posted by jiangfan <17...@qq.com>.
I now is to want to use the Camel-CXF call to the third party web services.
They provide to me they released WSDL documents :

 <?xml version="1.0" encoding="UTF-8" ?> 
- <wsdl:definitions name="BlfThirdIntegrateImplService"
targetNamespace="http://ws.cxfExample.ygsoft.com/"
xmlns:ns1="http://cxf.apache.org/bindings/xformat"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://ws.cxfExample.ygsoft.com/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <wsdl:types>
+ <xsd:schema attributeFormDefault="unqualified"
elementFormDefault="unqualified"
targetNamespace="http://ws.cxfExample.ygsoft.com/"
xmlns:tns="http://ws.cxfExample.ygsoft.com/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:element name="getZWItemsYW" type="tns:getZWItemsYW" /> 
+ <xsd:complexType name="getZWItemsYW">
  <xsd:sequence /> 
  </xsd:complexType>
  <xsd:element name="getZWItemsYWResponse" type="tns:getZWItemsYWResponse"
/> 
+ <xsd:complexType name="getZWItemsYWResponse">
- <xsd:sequence>
  <xsd:element minOccurs="0" name="return" type="xsd:string" /> 
  </xsd:sequence>
  </xsd:complexType>
  <xsd:element name="newQueryZWData" type="tns:newQueryZWData" /> 
+ <xsd:complexType name="newQueryZWData">
- <xsd:sequence>
  <xsd:element minOccurs="0" name="arg0" type="xsd:string" /> 
  <xsd:element minOccurs="0" name="arg1" type="xsd:string" /> 
  <xsd:element name="arg2" type="xsd:int" /> 
  <xsd:element minOccurs="0" name="arg3" type="xsd:string" /> 
  </xsd:sequence>
  </xsd:complexType>
  <xsd:element name="newQueryZWDataResponse"
type="tns:newQueryZWDataResponse" /> 
+ <xsd:complexType name="newQueryZWDataResponse">
- <xsd:sequence>
  <xsd:element minOccurs="0" name="return" type="xsd:string" /> 
  </xsd:sequence>
  </xsd:complexType>
  </xsd:schema>
  </wsdl:types>
+ <wsdl:message name="newQueryZWData">
  <wsdl:part element="tns:newQueryZWData" name="parameters" /> 
  </wsdl:message>
+ <wsdl:message name="newQueryZWDataResponse">
  <wsdl:part element="tns:newQueryZWDataResponse" name="parameters" /> 
  </wsdl:message>
- <wsdl:message name="getZWItemsYW">
  <wsdl:part element="tns:getZWItemsYW" name="parameters" /> 
  </wsdl:message>
- <wsdl:message name="getZWItemsYWResponse">
  <wsdl:part element="tns:getZWItemsYWResponse" name="parameters" /> 
  </wsdl:message>
- <wsdl:portType name="BlfThirdIntegrate">
- <wsdl:operation name="getZWItemsYW">
  <wsdl:input message="tns:getZWItemsYW" name="getZWItemsYW" /> 
  <wsdl:output message="tns:getZWItemsYWResponse"
name="getZWItemsYWResponse" /> 
  </wsdl:operation>
+ <wsdl:operation name="newQueryZWData">
  <wsdl:input message="tns:newQueryZWData" name="newQueryZWData" /> 
  <wsdl:output message="tns:newQueryZWDataResponse"
name="newQueryZWDataResponse" /> 
  </wsdl:operation>
  </wsdl:portType>
- <wsdl:binding name="BlfThirdIntegrateImplServiceSoapBinding"
type="tns:BlfThirdIntegrate">
  <soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" /> 
- <wsdl:operation name="getZWItemsYW">
  <soap:operation soapAction="" style="document" /> 
- <wsdl:input name="getZWItemsYW">
  <soap:body use="literal" /> 
  </wsdl:input>
- <wsdl:output name="getZWItemsYWResponse">
  <soap:body use="literal" /> 
  </wsdl:output>
  </wsdl:operation>
+ <wsdl:operation name="newQueryZWData">
  <soap:operation soapAction="" style="document" /> 
- <wsdl:input name="newQueryZWData">
  <soap:body use="literal" /> 
  </wsdl:input>
- <wsdl:output name="newQueryZWDataResponse">
  <soap:body use="literal" /> 
  </wsdl:output>
  </wsdl:operation>
  </wsdl:binding>
- <wsdl:service name="BlfThirdIntegrateImplService">
- <wsdl:port binding="tns:BlfThirdIntegrateImplServiceSoapBinding"
name="BlfThirdIntegrateImplPort">
  <soap:address
location="http://127.0.0.1:8080/YGFMISWeb/services/BlfThirdIntegrate" /> 
  </wsdl:port>
  </wsdl:service>
  </wsdl:definitions>


Now I want to call the service of the method is getZWItemsYW 
My camel routing is like this :
<camel:route id="cxf-example">
    <camel:from uri="jms:queue:cxf-example?jmsMessageType=Text" />
    <camel:to
uri="cxf://http://127.0.0.1:8080/YGFMISWeb/services/BlfThirdIntegrate?wsdl?wsdlURL=src/main/resources/BlfThirdIntegrate.wsdl&amp;serviceName={http://ws.cxfExample.ygsoft.com/}BlfThirdIntegrateImplService&amp;portName={http://ws.cxfExample.ygsoft.com/}BlfThirdIntegrateImplPort&amp;dataFormat=MESSAGE"
/>
    <camel:log loggingLevel="INFO" message="&gt;&gt;&gt;${body}" />
</camel:route>

I have some questions:
1.Write like this, can I call for example Axis released service 
2.One of the local written, I guess is basic it is, don't know the correct
this how to write:
<camel:to
uri="cxf://http://127.0.0.1:8080/YGFMISWeb/services/BlfThirdIntegrate?wsdl?wsdlURL=src/main/resources/BlfThirdIntegrate.wsdl&amp;serviceName={http://ws.cxfExample.ygsoft.com/}BlfThirdIntegrateImplService&amp;portName={http://ws.cxfExample.ygsoft.com/}BlfThirdIntegrateImplPort&amp;dataFormat=MESSAGE"
/>
Because to finish this section of time I found that didn't write operation
in



--
View this message in context: http://camel.465427.n5.nabble.com/CXF-problem-how-to-use-Camel-Cxf-to-invoke-a-webservice-tp5107111p5109194.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: CXF -- problem how to use Camel-Cxf to invoke a webservice

Posted by jiangfan <17...@qq.com>.
It's so kind of you! Thanks again! Helped me a lot !


--
View this message in context: http://camel.465427.n5.nabble.com/CXF-problem-how-to-use-Camel-Cxf-to-invoke-a-webservice-tp5107111p5109015.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: CXF -- problem how to use Camel-Cxf to invoke a webservice

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Dec 29, 2011 at 10:15 AM, jiangfan <17...@qq.com> wrote:
> Thanks for the guidance Claus!
>

It was Willem :)

There is also some CXF examples
http://camel.apache.org/examples

But they tend to focused on exposes a web service using Camel and CXF.
And not as much on invoking an external web service.

There is also sometimes good 3rd party blog posts and articles. You
may find some about web services and Camel
http://camel.apache.org/articles.html


> --
> View this message in context: http://camel.465427.n5.nabble.com/CXF-problem-how-to-use-Camel-Cxf-to-invoke-a-webservice-tp5107111p5107253.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/

Re: CXF -- problem how to use Camel-Cxf to invoke a webservice

Posted by jiangfan <17...@qq.com>.
Thanks for the guidance Claus!

--
View this message in context: http://camel.465427.n5.nabble.com/CXF-problem-how-to-use-Camel-Cxf-to-invoke-a-webservice-tp5107111p5107253.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: CXF -- problem how to use Camel-Cxf to invoke a webservice

Posted by Willem Jiang <wi...@gmail.com>.
Please take a look at the camel-cxf wiki page[1]
There are lots of example that you can use.

[1] http://camel.apache.org/cxf.html

On Thu Dec 29 16:16:44 2011, jiangfan wrote:
> Hi,
> I used to do, to write a bean, then use the bean webservice to call .
> like this:
>              <camel:camelContext autoStartup="true" trace="true">
> 		<camel:route id="old-example">
> 			<camel:from uri="jms:queue:old-example?jmsMessageType=Text" />
> 			<camel:to uri="bean:serviceOldInvokerBean?method=invokerSomeService" />
> 		</camel:route>
>
> 	</camel:camelContext>
> 	<bean id="serviceOldInvokerBean"
> class="com.ygsoft.cxfExample.bean.ServiceOldInvokerBean" />
>
> Now I want to use a camel-CXF component to call webservice
>
> can you show me a example ?
>
>
> Thanks in advance,
> Jiangfan
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/CXF-problem-how-to-use-Camel-Cxf-to-invoke-a-webservice-tp5107111p5107111.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>



-- 
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
         http://jnn.javaeye.com (Chinese)
Twitter: willemjiang 
Weibo: willemjiang