8 Replies Latest reply on Mar 16, 2011 10:36 AM by atlantix

    Need "cxf:cxfEndpoint" clarification

    atlantix Newbie

      Hello,

       

      I have created a wsdl file

      and then I have created the web service using wsdl-first archetype,

      I built my project and implemented a Java class ex.tuto.exercice.MDMServerSoapImpl that impelements a interface generated with the code gen plugin

      I added the following in my beans.xml file

       

                              

       

       

      and I added the following annotations to my Impl class

      // START SNIPPET: e1

      @WebServiceProvider()

      @ServiceMode(Mode.MESSAGE)

       

       

      is this correct ?

      My understanding is that by adding the cxf endpoint and the route, camel route will be listening to any SOAP call to cxf/MDMServerSoapService  that I have specified in the cxf endpoint address , and then the route will save the body of the query in the file endpoint

      if this is correct then I see its not working ...

       

      Edited by: atlantix on Mar 11, 2011 9:25 AM

        • 1. Re: Need "cxf:cxfEndpoint" clarification
          Willem Jiang Master

          Hi

           

          The serviceClass attribute of the cxfEndpoint is for the SEI (Service Endpoint Interface). It can't be the implementation class.

           

          You can find some example to how to use the camel-cxf endpoint here[1][2]

           

          http://camel.apache.org/cxf.html

          http://camel.apache.org/cxf-example.html

           

          Willem

          • 2. Re: Need "cxf:cxfEndpoint" clarification
            atlantix Newbie

            first thanks for the answer, BUT I think your answer is not really consistent with the example given in the link you sent me

             

             

            I see that the serviceClass="org.apache.camel.example.cxf.provider.GreeterProvider"

            is actually a class, you can check that in the source code

             

            I also replaced the Impl class with the interface but still not working

             

             

            so here the cxf-example I was following

             

             

            • 3. Re: Need "cxf:cxfEndpoint" clarification
              Willem Jiang Master

              What's the stack trace?

              Are you try to process the SOAP message with the WebServiceProvider ?

              You can find the example here[1]

               

              http://camel.apache.org/cxf-example.html#CXFExample-CXFexampleforusingtheWebServiceProviderAPI

               

              Willem

              • 4. Re: Need "cxf:cxfEndpoint" clarification
                atlantix Newbie

                Actually , there were no errors

                seems that the route is not called at all

                 

                when I send a SOAP query using SOAPUI the service is running (Response is sent back to soapui and I successfully could debug the service)

                 

                what I want actually is to intercept the call to do something before it hit my Service implementation (example throttling / validation or anything before hitting my service)

                 

                 

                Please again that same link that you sent me is what I am following

                 

                 

                 

                 

                 

                Thanks

                • 5. Re: Need "cxf:cxfEndpoint" clarification
                  atlantix Newbie

                  Here is a better explanation of my problem:

                   

                   

                   

                  I have a running webservice that I created using wsdl-first archetype

                  to deploy this webservice I did the following

                   

                   

                  I created a jax ws endpoint

                   

                  <jaxws:endpoint id="HTTPEndpoint" implementor="ex.tuto.exercice.MDMServerSoapImpl"

                  address="/MDMServerSoapService" wsdlLocation="wsdl/FBN.wsdl"

                  endpointName="e:MDM_ServerSoap" serviceName="s:MDM_Server"

                  xmlns:e="http://www.multispeak.org/Version_4.1_Release" xmlns:s="http://www.multispeak.org/Version_4.1_Release" />

                   

                  <jaxws:endpoint id="HTTPEndpoint12" implementor="ex.tuto.exercice.MDMServerSoapImpl"

                  address="/MDMServerSoapService" wsdlLocation="wsdl/FBN.wsdl"

                  endpointName="e:MDM_ServerSoap12" serviceName="s:MDM_Server"

                  xmlns:e="http://www.multispeak.org/Version_4.1_Release" xmlns:s="http://www.multispeak.org/Version_4.1_Release" />

                   

                   

                  Line: -


                   

                  then my web service is running and I can access its wsdl by doing this

                  http://localhost:8181/cxf/MDMServerSoapService?wsdl

                   

                  I also dont know any way to configure the default 8181 port et the /cxf

                   

                  Now here is what I want to do :

                   

                  I want to intercept any call to this webservice usng camel,

                  do some checks edit the SOAP message and then foward to the original class , my jax ws existing service will run normally as if it recieved a regular SOAP query

                   

                   

                  I created a route from cxf:bean:HTTPEndpoint ---> didnt work

                   

                  I added a cxf endpoint as follow

                          <cxf:cxfEndpoint id="soapMessageEndpoint"

                               serviceClass="org.multispeak.version_4_1_release.MDMServerSoap"

                                 address="/MDMServerSoapService"

                                    wsdlURL="wsdl/FBN.wsdl"

                            endpointName="e:MDM_ServerSoap" serviceName="s:MDM_Server"

                            xmlns:e="http://www.multispeak.org/Version_4.1_Release" xmlns:s="http://www.multispeak.org/Version_4.1_Release" />

                   

                   

                  ---> still didnt work

                   

                   

                  what worked for me is the following

                   

                   

                            from("jetty:http://localhost:8181/cxf/MDMServerSoapService")

                                      .process(new Processor() {

                                           public void process(Exchange exchange) throws Exception {

                                                InputStream in = (InputStream) exchange.getIn()

                                                          .getBody();

                                                String soapMessage = org.apache.camel.component.cxf.util.CxfUtils

                                                          .getStringFromInputStream(in);

                                                org.w3c.dom.Document doc = XMLUtils.parse(soapMessage);

                                                // String formattedBlock =

                                                // XMLUtils.toString(doc.getElementsByTagName("ver:FormattedBlockNotification").item(0));

                   

                                                String soapBody = XMLUtils.toString(doc

                                                          .getElementsByTagName(

                                                                    "ver:FormattedBlockNotification").item(

                                                                    0));

                   

                                                exchange.getIn().setBody(soapBody);

                                           }

                                      }).unmarshal(jaxb).process(new Processor() {

                                           public void process(Exchange exchange) throws Exception {

                                                FormattedBlockNotification formattedBlockNotification = (FormattedBlockNotification) exchange

                                                          .getIn().getBody();

                                                formattedBlockNotification.toString();

                                                Message out = exchange.getOut();

                   

                                                //out.setHeader(CxfConstants.OPERATION_NAME, "FormattedBlockNotification" );

                   

                                                out.setBody(new Object[]{formattedBlockNotification.getChangedMeterReads(),formattedBlockNotification.getTransactionID()});

                   

                                           }

                                      }).to("cxf:bean:soapMessageEndpoint");

                   

                   

                   

                  but the .to("cxf:bean:soapMessageEndpoint");  didnt seem to to run correctly

                   

                   

                   

                   

                  Any advice ??

                   

                  Edited by: atlantix on Mar 14, 2011 4:13 PM

                   

                  Edited by: atlantix on Mar 14, 2011 4:14 PM

                  • 6. Re: Need "cxf:cxfEndpoint" clarification
                    atlantix Newbie

                    seems that what  I want to do is not doable ,

                     

                    I cant have a cxf endpoint and jaxws endpoint pointing the same addresse

                    the jaxws endpoint is always being called/

                    • 7. Re: Need "cxf:cxfEndpoint" clarification
                      Willem Jiang Master

                      Why do you want to put the cxf endpoint and jaxws endpoint at the same address?

                      It's not making any sense.

                       

                      cxfEndpoint can help you route the message into camel route, and you can do the same thing by create a camel context inside the jaxws implementation.

                       

                      If you just want to handle the request message in some kind of low level (without marshaling the request into a method invocation) you can use the camel-jetty to deal with the http transport and leave the message processing in the camel route.

                       

                      Willem

                      • 8. Re: Need "cxf:cxfEndpoint" clarification
                        atlantix Newbie

                        correct it makes no sense

                        I ended up using jetty endpoint

                         

                        the idea behind it was the following

                         

                        I have developed a ws and configured it with  jaxws ,

                         

                        SOAP Query -


                        > JAXWS -


                        > Response

                         

                         

                         

                        I wanted to keep what I have already and add an interceptor that just check my soap query and then either send

                         

                         

                        SOAP Query -


                        > CAMEL  -


                        >Edited SOAP Query----


                        > JAXWS -


                        > Resp.

                                                      

                                                      

                                                     \/

                                                   OTHER STUFF

                         

                        Edited by: atlantix on Mar 16, 2011 2:35 PM