4 Replies Latest reply on Jan 23, 2009 4:16 PM by Brett Levasseur

    Camel and SOAP

    Brett Levasseur Newbie



      I have been asked to create an example using Camel where a raw SOAP message can be sent from a client to a server. I am new to Camel and so I downloaded the fuse mediation router version 1.5.2. I did find the camel-example-cxf directory. I believe that the CXF Provider example in this directory is close to what I need. However I have been asked to come up with a solution that does not involve CXF. Does anyone know of an example where you can use raw SOAP messages with Camel like the Provider example without using CXF? Thanks.



        • 1. Re: Camel and SOAP
          Claus Ibsen Master

          If not using CXF and you want webservices then what else webservice framework would you use?


          You could use raw HTTP using camel-jetty

          • 2. Re: Camel and SOAP
            Brett Levasseur Newbie

            The decision as to which webservice framework to use has not been decided yet. That is part of the reason why I have been asked to come up with some different examples. I tried coming up with an example today that would use jetty like you suggested. While defining my server routes I was able to setup a from("jetty:http ... to create my server.


            I want my soap message to go from the url to a method in a java class so that I can check for authentication. I found examples that implemented the class org.apache.camel.Processor to send incoming messages to the method public void process(Exchange exchange). I was able to get this to work however I am not sure how to take this exchange object and extract my original soap message. I do not think I can just get back my original javax.xml.soap.SOAPMessage object, however I did discover that I could get an org.apache.camel.component.http.HttpMessage object by using HttpMessage message = (HttpMessage)exchange.getIn().getBody(HttpMessage.class).


            I did not have enough time to go through all of this today, but do you think using the HttpMessage object is the right way to be able to retrieve information from my original soap message, or do you know of some other method that may be better? Thanks.

            • 3. Re: Camel and SOAP
              Claus Ibsen Master



              Camel-Jetty is for raw http services. So it will contain the text that was sent to it from the webbrowser.


              So the data type is like: String containing the raw http the web browser sends.


              So if you want this String to be some sort of SOAP/XML object then you must parse it or use some sort of data formatter than can take the raw String and convert it to SOAP.


              That is why most people will use some sort of webservice framework to let it handle at that.


              Camel has XPath support so you can use it to get some stuff out of the raw data since its XML when its web service.


              You can also get it as org.w3c.Document object in Camel using

              Document doc = exchange.getIn().getBody(Document.class);


              Camel has build in type converters that can do this.


              There is a tutorial here how to use Axis 1.4 with Camel



              Other webserivce frameworks that I know of

              - Axis 2

              - Spring Web Service

              • 4. Re: Camel and SOAP
                Brett Levasseur Newbie

                Thanks for the advice. I will have to take some time to go through the tutorial and try some other things, but I think this should be helpful.