You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Charles Moulliard <cm...@gmail.com> on 2011/04/19 19:19:59 UTC
How can we set the SOAP Operation name to be called when using camel-soap
Hi,
I create a simple camel route to generate a SOAP message and call the
webserver using http client. How can I configure camel, soap to send
the correct SOAP Message to my webservice ?
Camel route
**************
<bean id="elStrategy"
class="org.apache.camel.dataformat.soap.name.ServiceInterfaceStrategy">
<constructor-arg index="0"
value="org.openuri._2004._04.helloworld.EndpointInterface"/>
<constructor-arg index="1" value="true"/>
</bean>
<camelContext trace="true" xmlns="http://camel.apache.org/schema/spring">
<jmxAgent id="agent" createConnector="true"/>
<dataFormats>
<soapjaxb id="soapFormat" contextPath="com.bar.foo.test"
elementNameStrategyRef="elStrategy"/>
</dataFormats>
<route>
<from uri="file:./target/dataecho?noop=true"/>
<convertBodyTo type="String"/>
<log message="Echo message received : ${body}"/>
<bean ref="enrich" method="transform"/> // This is where
we create the Foo object = SOAP Body
<marshal ref="soapFormat"/>
<to uri="http://localhost:9090/redpill/WebService"/>
<log message="SOAP message received : ${body}"/>
</route>
<route id="cxf-to-queue">
<from uri="cxf:bean:redPillWS?dataFormat=POJO"/>
<log message="SOAP message received : ${body}"/>
<transform>
<constant>OK</constant>
</transform>
</route>
WSDL
*******
<definitions name="TestService"
targetNamespace="http://www.openuri.org/2004/04/HelloWorld"
xmlns:tns="http://www.openuri.org/2004/04/HelloWorld"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
<types>
<xs:schema targetNamespace='http://foo.bar.com/test'
version='1.0' xmlns:tns='http://foo.bar.com/test'
xmlns:xs='http://www.w3.org/2001/XMLSchema'>
<xs:complexType name="foo">
<xs:sequence>
<xs:element name="arg0" type="xs:int"/>
<xs:element name="arg1" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</types>
<message name="EndpointInterface_echo">
<part name="String_1" type="xsd:string"/>
</message>
<message name="EndpointInterface_echoResponse">
<part name="result" type="xsd:string"/>
</message>
<portType name="EndpointInterface">
<operation name="echo" parameterOrder="String_1">
<input message="tns:EndpointInterface_echo"/>
<output message="tns:EndpointInterface_echoResponse"/>
</operation>
</portType>
<binding name="EndpointInterfaceBinding" type="tns:EndpointInterface">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
style="rpc"/>
<operation name="echo">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"
namespace="http://www.openuri.org/2004/04/HelloWorld"/>
</input>
<output>
<soap:body use="literal"
namespace="http://www.openuri.org/2004/04/HelloWorld"/>
</output>
</operation>
</binding>
<service name="TestService">
<port name="EndpointInterfacePort"
binding="tns:EndpointInterfaceBinding">
<soap:address location="http://localhost:9090/webservices/echo"/>
</port>
</service>
</definitions>
Message send to the WebService
***************************************
<ns2:Envelope xmlns:ns2="http://schemas.xmlsoap.org/soap/envelope/">
<ns2:Body>
<ns3:foo xmlns:ns3="http://foo.bar.com/test">
<arg0>0</arg0>
<arg1>Hello, Fuse Students</arg1>
</ns3:foo>
</ns2:Body>
</ns2:Envelope>
Error generated
*******************
1977012692@qtp-2116352311-0 WARN
[org.apache.cxf.phase.PhaseInterceptorChain] - Interceptor for
{http://www.openuri.org/2004/04/HelloWorld}EndpointInterfaceService
has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Message part
{http://foo.bar.com/test}foo was not recognized. (Does it exist in
service WSDL?)
at org.apache.cxf.interceptor.BareInInterceptor.handleMessage(BareInInterceptor.java:133)
at org.apache.cxf.binding.soap.interceptor.RPCInInterceptor.handleMessage(RPCInInterceptor.java:111)
The SOAP Action to be called is echo and not foo ................. and
so the soap message to be generated should be
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:hel="http://www.openuri.org/2004/04/HelloWorld">
<soapenv:Header/>
<soapenv:Body>
<hel:echo>
<String_1>blabla</String_1>
</hel:echo>
</soapenv:Body>
</soapenv:Envelope>
Regards,
Charles Moulliard
Sr. Principal Solution Architect - FuseSource
Apache Committer
Blog : http://cmoulliard.blogspot.com
Twitter : http://twitter.com/cmoulliard
Linkedin : http://www.linkedin.com/in/charlesmoulliard
Skype: cmoulliard
Re: How can we set the SOAP Operation name to be called when using camel-soap
Posted by Claus Ibsen <cl...@gmail.com>.
There is a <setHeader> you can use to set a header with the operation
name. Something like
<setHeader headerName="operationName"><constant>foobar</constant></setHeader>
On Tue, Apr 19, 2011 at 7:19 PM, Charles Moulliard <cm...@gmail.com> wrote:
> Hi,
>
> I create a simple camel route to generate a SOAP message and call the
> webserver using http client. How can I configure camel, soap to send
> the correct SOAP Message to my webservice ?
>
> Camel route
> **************
>
> <bean id="elStrategy"
> class="org.apache.camel.dataformat.soap.name.ServiceInterfaceStrategy">
> <constructor-arg index="0"
> value="org.openuri._2004._04.helloworld.EndpointInterface"/>
> <constructor-arg index="1" value="true"/>
> </bean>
>
> <camelContext trace="true" xmlns="http://camel.apache.org/schema/spring">
> <jmxAgent id="agent" createConnector="true"/>
>
> <dataFormats>
> <soapjaxb id="soapFormat" contextPath="com.bar.foo.test"
> elementNameStrategyRef="elStrategy"/>
> </dataFormats>
>
> <route>
> <from uri="file:./target/dataecho?noop=true"/>
> <convertBodyTo type="String"/>
> <log message="Echo message received : ${body}"/>
> <bean ref="enrich" method="transform"/> // This is where
> we create the Foo object = SOAP Body
> <marshal ref="soapFormat"/>
> <to uri="http://localhost:9090/redpill/WebService"/>
> <log message="SOAP message received : ${body}"/>
>
> </route>
>
> <route id="cxf-to-queue">
> <from uri="cxf:bean:redPillWS?dataFormat=POJO"/>
> <log message="SOAP message received : ${body}"/>
> <transform>
> <constant>OK</constant>
> </transform>
> </route>
>
> WSDL
> *******
> <definitions name="TestService"
> targetNamespace="http://www.openuri.org/2004/04/HelloWorld"
> xmlns:tns="http://www.openuri.org/2004/04/HelloWorld"
> xmlns="http://schemas.xmlsoap.org/wsdl/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
> <types>
> <xs:schema targetNamespace='http://foo.bar.com/test'
> version='1.0' xmlns:tns='http://foo.bar.com/test'
> xmlns:xs='http://www.w3.org/2001/XMLSchema'>
> <xs:complexType name="foo">
> <xs:sequence>
> <xs:element name="arg0" type="xs:int"/>
> <xs:element name="arg1" type="xs:string"/>
> </xs:sequence>
> </xs:complexType>
> </xs:schema>
> </types>
>
> <message name="EndpointInterface_echo">
> <part name="String_1" type="xsd:string"/>
> </message>
> <message name="EndpointInterface_echoResponse">
> <part name="result" type="xsd:string"/>
> </message>
>
> <portType name="EndpointInterface">
> <operation name="echo" parameterOrder="String_1">
> <input message="tns:EndpointInterface_echo"/>
> <output message="tns:EndpointInterface_echoResponse"/>
> </operation>
> </portType>
>
> <binding name="EndpointInterfaceBinding" type="tns:EndpointInterface">
> <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
> style="rpc"/>
> <operation name="echo">
> <soap:operation soapAction=""/>
> <input>
> <soap:body use="literal"
> namespace="http://www.openuri.org/2004/04/HelloWorld"/>
> </input>
> <output>
> <soap:body use="literal"
> namespace="http://www.openuri.org/2004/04/HelloWorld"/>
> </output>
> </operation>
> </binding>
>
> <service name="TestService">
> <port name="EndpointInterfacePort"
> binding="tns:EndpointInterfaceBinding">
> <soap:address location="http://localhost:9090/webservices/echo"/>
> </port>
> </service>
> </definitions>
>
> Message send to the WebService
> ***************************************
> <ns2:Envelope xmlns:ns2="http://schemas.xmlsoap.org/soap/envelope/">
> <ns2:Body>
> <ns3:foo xmlns:ns3="http://foo.bar.com/test">
> <arg0>0</arg0>
> <arg1>Hello, Fuse Students</arg1>
> </ns3:foo>
> </ns2:Body>
> </ns2:Envelope>
>
> Error generated
> *******************
> 1977012692@qtp-2116352311-0 WARN
> [org.apache.cxf.phase.PhaseInterceptorChain] - Interceptor for
> {http://www.openuri.org/2004/04/HelloWorld}EndpointInterfaceService
> has thrown exception, unwinding now
> org.apache.cxf.interceptor.Fault: Message part
> {http://foo.bar.com/test}foo was not recognized. (Does it exist in
> service WSDL?)
> at org.apache.cxf.interceptor.BareInInterceptor.handleMessage(BareInInterceptor.java:133)
> at org.apache.cxf.binding.soap.interceptor.RPCInInterceptor.handleMessage(RPCInInterceptor.java:111)
>
> The SOAP Action to be called is echo and not foo ................. and
> so the soap message to be generated should be
>
> <soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:hel="http://www.openuri.org/2004/04/HelloWorld">
> <soapenv:Header/>
> <soapenv:Body>
> <hel:echo>
> <String_1>blabla</String_1>
> </hel:echo>
> </soapenv:Body>
> </soapenv:Envelope>
>
> Regards,
>
> Charles Moulliard
>
> Sr. Principal Solution Architect - FuseSource
> Apache Committer
>
> Blog : http://cmoulliard.blogspot.com
> Twitter : http://twitter.com/cmoulliard
> Linkedin : http://www.linkedin.com/in/charlesmoulliard
> Skype: cmoulliard
>
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
CamelOne 2011: http://fusesource.com/camelone2011/
Twitter: davsclaus
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/
Re: How can we set the SOAP Operation name to be called when using
camel-soap
Posted by Christian Schneider <ch...@die-schneider.net>.
Hi Charles,
camel-soap uses the annotations on the code to determine the soap
action. So you could either provide the correct annotation or if you
generate the code from wsdl provide the
soap action in the wsdl.
As you added a wsdl to the mail I guess you are generating the java
code. So I think the problem is that the wsdl contains <soap:operation
soapAction=""/> which explicitly tells the generator
to use an empty soap action.
Christian
Am 19.04.2011 19:19, schrieb Charles Moulliard:
> Hi,
>
> I create a simple camel route to generate a SOAP message and call the
> webserver using http client. How can I configure camel, soap to send
> the correct SOAP Message to my webservice ?
>
> Camel route
> **************
>
> <bean id="elStrategy"
> class="org.apache.camel.dataformat.soap.name.ServiceInterfaceStrategy">
> <constructor-arg index="0"
> value="org.openuri._2004._04.helloworld.EndpointInterface"/>
> <constructor-arg index="1" value="true"/>
> </bean>
>
> <camelContext trace="true" xmlns="http://camel.apache.org/schema/spring">
> <jmxAgent id="agent" createConnector="true"/>
>
> <dataFormats>
> <soapjaxb id="soapFormat" contextPath="com.bar.foo.test"
> elementNameStrategyRef="elStrategy"/>
> </dataFormats>
>
> <route>
> <from uri="file:./target/dataecho?noop=true"/>
> <convertBodyTo type="String"/>
> <log message="Echo message received : ${body}"/>
> <bean ref="enrich" method="transform"/> // This is where
> we create the Foo object = SOAP Body
> <marshal ref="soapFormat"/>
> <to uri="http://localhost:9090/redpill/WebService"/>
> <log message="SOAP message received : ${body}"/>
>
> </route>
>
> <route id="cxf-to-queue">
> <from uri="cxf:bean:redPillWS?dataFormat=POJO"/>
> <log message="SOAP message received : ${body}"/>
> <transform>
> <constant>OK</constant>
> </transform>
> </route>
>
> WSDL
> *******
> <definitions name="TestService"
> targetNamespace="http://www.openuri.org/2004/04/HelloWorld"
> xmlns:tns="http://www.openuri.org/2004/04/HelloWorld"
> xmlns="http://schemas.xmlsoap.org/wsdl/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
> <types>
> <xs:schema targetNamespace='http://foo.bar.com/test'
> version='1.0' xmlns:tns='http://foo.bar.com/test'
> xmlns:xs='http://www.w3.org/2001/XMLSchema'>
> <xs:complexType name="foo">
> <xs:sequence>
> <xs:element name="arg0" type="xs:int"/>
> <xs:element name="arg1" type="xs:string"/>
> </xs:sequence>
> </xs:complexType>
> </xs:schema>
> </types>
>
> <message name="EndpointInterface_echo">
> <part name="String_1" type="xsd:string"/>
> </message>
> <message name="EndpointInterface_echoResponse">
> <part name="result" type="xsd:string"/>
> </message>
>
> <portType name="EndpointInterface">
> <operation name="echo" parameterOrder="String_1">
> <input message="tns:EndpointInterface_echo"/>
> <output message="tns:EndpointInterface_echoResponse"/>
> </operation>
> </portType>
>
> <binding name="EndpointInterfaceBinding" type="tns:EndpointInterface">
> <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
> style="rpc"/>
> <operation name="echo">
> <soap:operation soapAction=""/>
> <input>
> <soap:body use="literal"
> namespace="http://www.openuri.org/2004/04/HelloWorld"/>
> </input>
> <output>
> <soap:body use="literal"
> namespace="http://www.openuri.org/2004/04/HelloWorld"/>
> </output>
> </operation>
> </binding>
>
> <service name="TestService">
> <port name="EndpointInterfacePort"
> binding="tns:EndpointInterfaceBinding">
> <soap:address location="http://localhost:9090/webservices/echo"/>
> </port>
> </service>
> </definitions>
>
> Message send to the WebService
> ***************************************
> <ns2:Envelope xmlns:ns2="http://schemas.xmlsoap.org/soap/envelope/">
> <ns2:Body>
> <ns3:foo xmlns:ns3="http://foo.bar.com/test">
> <arg0>0</arg0>
> <arg1>Hello, Fuse Students</arg1>
> </ns3:foo>
> </ns2:Body>
> </ns2:Envelope>
>
> Error generated
> *******************
> 1977012692@qtp-2116352311-0 WARN
> [org.apache.cxf.phase.PhaseInterceptorChain] - Interceptor for
> {http://www.openuri.org/2004/04/HelloWorld}EndpointInterfaceService
> has thrown exception, unwinding now
> org.apache.cxf.interceptor.Fault: Message part
> {http://foo.bar.com/test}foo was not recognized. (Does it exist in
> service WSDL?)
> at org.apache.cxf.interceptor.BareInInterceptor.handleMessage(BareInInterceptor.java:133)
> at org.apache.cxf.binding.soap.interceptor.RPCInInterceptor.handleMessage(RPCInInterceptor.java:111)
>
> The SOAP Action to be called is echo and not foo ................. and
> so the soap message to be generated should be
>
> <soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:hel="http://www.openuri.org/2004/04/HelloWorld">
> <soapenv:Header/>
> <soapenv:Body>
> <hel:echo>
> <String_1>blabla</String_1>
> </hel:echo>
> </soapenv:Body>
> </soapenv:Envelope>
>
> Regards,
>
> Charles Moulliard
>
> Sr. Principal Solution Architect - FuseSource
> Apache Committer
>
> Blog : http://cmoulliard.blogspot.com
> Twitter : http://twitter.com/cmoulliard
> Linkedin : http://www.linkedin.com/in/charlesmoulliard
> Skype: cmoulliard
>
--
----
http://www.liquid-reality.de