1 2 Previous Next 16 Replies Latest reply on Jul 5, 2013 11:49 PM by Freeman(Yue) Fang

    Cannot route SOAP messages

    Anirban Gupta Newbie

      Hi,

       

      I was unable to route SOAP messages using Apache Camel. I was trying a simple example. The SOAP message is

       

      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:java="http://java.com/">

         <soapenv:Header/>

         <soapenv:Body>

            <java:sayHello>

               <!--Optional:-->

               <arg0>test</arg0>

            </java:sayHello>

         </soapenv:Body>

      </soapenv:Envelope>

       

      My camel-context.xml defined in Spring DSL is:

       

      <?xml version="1.0" encoding="UTF-8"?>
      <!--
          Licensed to the Apache Software Foundation (ASF) under one or more
          contributor license agreements.  See the NOTICE file distributed with
          this work for additional information regarding copyright ownership.
          The ASF licenses this file to You under the Apache License, Version 2.0
          (the "License"); you may not use this file except in compliance with
          the License.  You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

          Unless required by applicable law or agreed to in writing, software
          distributed under the License is distributed on an "AS IS" BASIS,
          WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
          See the License for the specific language governing permissions and
          limitations under the License.
      -->

      <beans xmlns="http://www.springframework.org/schema/beans"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:camel="http://camel.apache.org/schema/spring"
             xsi:schemaLocation="
               http://www.springframework.org/schema/beans
               http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
               http://camel.apache.org/schema/spring
               http://camel.apache.org/schema/spring/camel-spring.xsd">

        <import resource="classpath:META-INF/spring/camel-cxf.xml" />

        <camelContext xmlns="http://camel.apache.org/schema/spring"
            xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
            xmlns:java="http://java.com/">
          <route>
             
              <from uri="cxf:bean:helloConsumerEndpoint"/>
              <choice>
                  <when>
                      <xpath>/soapenv:Envelope/soapenv:Body/java:sayHello/arg0 = 'Anirban'</xpath>
                      <log message="UK message"/>
                      <to uri="file:D:/workspace/ExposeWS/target/messages/uk"/>
                  </when>
                  <otherwise>
                      <log message="Other message"/>
                      <to uri="file:D:/workspace/ExposeWS/target/messages/others"/>
                  </otherwise>
              </choice>
          </route>
      </camelContext>

      </beans>

       

      I deployed the project containing this route in JBoss Fuse and when I hit it with the above SOAP message using SOAP UI, I was not expecting any response in SOAP UI and the SOAP message in target locations, but I received the following error in SOAP UI:

       

      <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">

         <soap:Body>

            <soap:Fault>

               <faultcode>soap:Server</faultcode>

               <faultstring>Error during type conversion from type: org.apache.cxf.message.MessageContentsList to the required type: org.w3c.dom.Document with value [test] due org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.</faultstring>

            </soap:Fault>

         </soap:Body>

      </soap:Envelope>

       

      Please help.

       

      Regards,

      Anirban.

        1 2 Previous Next