You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Rupali Desai <rt...@gmail.com> on 2013/03/19 06:00:21 UTC

Publishing CXF web service as part of an existing webapp

Hello,

I created a web service using the CXF framework using an existing WSDL. I
was able to deploy it to jetty (enable SSL connector on jetty) and able to
access it both using http and https through client code.
Now I need to integrate this as part of an existing web application. I need
to do this using the extension mechanism for the web app.

So in the extension class which is registered with the web app , the web
service is published using the following code in the init method.

           this.cxfServlet = new CXFServlet();
            cxfServlet.init();
                        Bus bus = this.cxfServlet.getBus();
            BusFactory.setDefaultBus(bus);
            String currentPath = "path/towsdl";


            String wsdlLocation = currentPath + "/conf" + File.separator +
Sample.wsdl;

            // register service, the address should start with "/"
            int port = 8080
            String uri = "http://localhost:" + port + "/service/" +
"SampleService";
            Endpoint endpoint = Endpoint.create(new ServiceImpl());
            EndpointImpl cxfEndpoint = (EndpointImpl) endpoint;
            cxfEndpoint.setWsdlLocation(wsdlLocation);

            cxfEndpoint.publish(uri);
            cxfEndpoint.getInInterceptors().add(new LoggingInInterceptor());
            cxfEndpoint.getOutInterceptors().add(new
LoggingOutInterceptor());

Now when I  access the web service from client code using the URL  '
http://localhost:8080/service/SampleService . Everything works fine.
However when I try to access the service using https. The request is not
intercepted by CXF but is just  forwarded to the post method in the
extension class .
I have enabled SSL connector on jetty in jetty.xml. I can access the rest
of the web application fine on https.

What am I doing wrong here.

Thanks
RD