herman shafiq
herman shafiq

Reputation: 501

How to change SOAP Web service Endpoint URL and WSDL URL in Apache Camel

The requirement is SOAP WSDL Url and Endpoint URL must be different from each other. Im using Apache Camel and Apache CXF below is my blueprint but when i request at port 8043 there is no wsdl there when i change it to 9143 wsdl is there.

Need to expose wsdl on url: http://0.0.0.0:8043/Services/Interface/FSServices/FSServices.serviceagent?wsdl

Endpoint URL be: http://0.0.0.0:9143/Services/Interface/FSServices/FSServices.serviceagent/PortTypeEndpoint1/

<cxf:cxfEndpoint
        address="http://0.0.0.0:8043/Services/Interface/FSServices/FSServices.serviceagent"
        id="fsEndpoint" serviceClass="pk.com.herman.fs.operation.PortType">
        <cxf:properties>
            <entry key="publishedEndpointUrl" value="http://0.0.0.0:9143/Services/Interface/FSServices/FSServices.serviceagent/PortTypeEndpoint1/"/>
        </cxf:properties>
    </cxf:cxfEndpoint>

Upvotes: 1

Views: 1666

Answers (1)

mika
mika

Reputation: 71

Weird requirement. You could do this by adding an interceptor which disables the WSDLGetInterceptor interceptor.

Add Interceptor

<bean id="removeWSDLinterceptor"
    class="my.package.RemoveWSDLInterceptor" />

<cxf:cxfEndpoint address="http://0.0.0.0:8043/Services/Interface/FSServices/FSServices.serviceagent"
    id="fsEndpoint" serviceClass="pk.com.herman.fs.operation.PortType">
    <cxf:inInterceptors>
        <ref bean="removeWSDLinterceptor" />
    </cxf:inInterceptors>
</cxf:cxfEndpoint>

Interceptor

public class RemoveWSDLInterceptor extends AbstractPhaseInterceptor<Message> 
{

public RemoveWSDLInterceptor() {

    super(Phase.RECEIVE);
}

public void handleMessage(Message message) {
    WSDLGetInterceptor getWSDLInterceptor = null;
    InterceptorChain chain = message.getInterceptorChain();

    for(Iterator<Interceptor<? extends Message>> iter = chain.iterator(); iter.hasNext();) {
        Interceptor getWSDLInterceptor = iter.next();
        if (interceptor instanceof WSDLGetInterceptor) {
            getWSDLInterceptor = (WSDLGetInterceptor) interceptor;
        }
    }
    chain.remove(getWSDLInterceptor);
}

public void handleFault(Message messageParam) {
}
}

And then you can add a small jetty route to return the WSDL statically.

<route>
        <from uri="jetty://http://0.0.0.0:9143" />
        <to uri="language:constant:resource:file:/path/to/your/wsdlfile.wsdl"/>
</route>

Upvotes: 0

Related Questions