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

Reply via email to