Peter Well
Peter Well

Reputation: 25

Change EndPoint details in CXF ServiceInfo

The environment CXF2.2.6 and Spring 2.5. On Startup JBOSS I need to read CXF properties and change End point details. From basic reading it gives me the idea that CXF Service Info class (org.apache.cxf.service.model.ServiceInfo) handle bindings,endpoints,messages,schemas and so on.

I can Extend CXFServlet and create my own custom servlet. Please advise me the way I can give my own details to Endpoint in startup and override what is given in Spring.xml

Upvotes: 1

Views: 655

Answers (1)

The below Spring bean should do what you wanted. Why do you want to override  ServiceInfo class ? Any particular reason ?

import org.apache.cxf.Bus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.context.ServletContextAware;


public class CXFConfig implements InitializingBean{
    @Autowired
    Bus cxfBus;

    @Override
    public void afterPropertiesSet() throws Exception {
        EndpointImpl endpoint = new EndpointImpl(cxfBus, new GdsAutomationServiceProviderImpl());
        endpoint.setAddress("/public/api/service/v1");//WSDL URL
        endpoint.setPublishedEndpointUrl(getEndPointAddress());
        endpoint.publish();
    }

    public Bus getCxfBus() {
        return cxfBus;
    }

    public void setCxfBus(Bus cxfBus) {
        this.cxfBus = cxfBus;
    }


    public String getEndPointAddress() {
      //  Soap address location you need to define here
        return "address"
    }

    @Override
    public void setServletContext(ServletContext context) {
        context.getServerInfo();

    }
}

Upvotes: 2

Related Questions