Search code examples
javaapachewsdlcxfwsdl2java

Apache CXF wsdl2java: make service return original WSDL file


I am struggling big time offering a web service based on some WSDL file received from a customer. As described in details here, the WSDL file returned when appending a ?wsdl to the service URL like

http://never.mind/SomeService?wsdl

seems to be misinterpreted by SoapUI and this again prevents the customer from using the service!

I was now hoping that someone could help me understand if it is possible to make the get WSDL endpoint return the original WSDL file instead of some Apache CXF digested version?

Update: I just read somewhere that there is a WSDLGetInterceptor taking care of the get WSDL requests - can I maybe override that one?


Solution

  • I chose to override the getDocument method of the WSDLGetUtils class being used by the WSDLGetInterceptor. My version of the utils class MyWSDLGetUtilsis put into action via this interceptor:

    public class WsdlGetSoapInterceptor extends AbstractSoapInterceptor {
        public WsdlGetSoapInterceptor() {
            super(Phase.READ);
            addBefore(WSDLGetInterceptor.class.getName());
        }
    
        /** {@inheritDoc} */
        @Override
        public void handleMessage(final SoapMessage message) throws Fault {
            message.setContextualProperty(WSDLGetUtils.class.getName(), MyWSDLGetUtils.Instance);
        }
    }