Quantcast

exposing different operations under same service in camel + cxf routing.

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

exposing different operations under same service in camel + cxf routing.

anupamsen
This post has NOT been accepted by the mailing list yet.
Hi All,


I have a requirement where in i want to expose a single webservice with multiple methods. Something like


    <wsdl:portType name="ReportIncidentEndpoint">
        <wsdl:operation name="ReportIncident">
            <wsdl:input message="tns:inputReportIncident"/>
            <wsdl:output message="tns:outputReportIncident"/>
        </wsdl:operation>
        <wsdl:operation name="ReportSmallIncident">
            <wsdl:input message="tns:inputReportSmallIncident"/>
            <wsdl:output message="tns:outputReportSmallIncident"/>
        </wsdl:operation>
    </wsdl:portType>

now based on different operation I would like to trigger different camel routes / workflows. Is this possible in camel? I want to host this service in same port though.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: exposing different operations under same service in camel + cxf routing.

Michal Warecki
I think you should create central route and next use content based router.
Name of current operation is stored in header CxfConstants.OPERATION_NAME.

Something like this:
from(...cxf...)
            .choice()
                .when(header(CxfConstants.OPERATION_NAME).isEqualTo(operationA))
                    .to("direct:operationARoute")
                .when(header(CxfConstants.OPERATION_NAME).isEqualTo(operationB))
                    .to("direct:operationBRoute")
                .otherwise()
                    .to("direct:unsupportedOperation");
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: exposing different operations under same service in camel + cxf routing.

anupamsen
camel-example-cxf-proxy.rar
Hi There,

Thanks for the reply. My goal is to expose a WS as an endpoint in Camel-CXF and based on the WS operation triggered by an external WS consumer I need to trigger the route/workflow. I have attached the example where I try to achieve it in the camel-config.xml. The following is the excerpt -


                        <from uri="cxf:bean:reportIncident" />
                        <camel:choice>
                                <camel:when>
                                        <camel:ognl>request.headers.operationName == 'ReportIncident'</camel:ognl>
                                       
                                        <to uri="bean:enrichBean" />
                                       
                                        <to ref="callRealWebService" />
                                </camel:when>
                                <camel:otherwise>
                                       
                                        <to ref="callRealWebService" />
                                       
                                        <to uri="log:output" />
                                </camel:otherwise>

In the first case, if the operation as per the WSDL is ReportIncident then I try to enrich the payload, else I don't. Its just a sample project from the camel examples with minor modification.

 I tried using -
<camel:simple>${header.operationName} == 'ReportIncident'</camel:simple>

and it didnt work, neither can I see any header for operationName.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: exposing different operations under same service in camel + cxf routing.

ychawla
Hi,
Have you tried turning on the tracer to see what headers are on your exchange?  A simple filter such as this should work:

                        <camel:filter>
                                <camel:simple>${in.headers.operationName} == 'SearchRequest'</camel:simple>
                                <camel:log message="Search Request has been invoked"/>
                        </camel:filter>

Try looking at all the headers on your exchange and make sure the operationName exists.  The framework should provide that header to you.

Thanks,
Yogesh
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: exposing different operations under same service in camel + cxf routing.

anupamsen
Following is the header that I see in the logs when run with "mvn camel:run" and routed to log uaing show header option like below-

<to uri="log:before?showHeaders=true"/>.

I don't see no operationName header -

Headers:{SOAPAction="http://reportincident.example.camel.apache.org/ReportIncident", accept-encoding=gzip,deflate, Host=localhost:9080, content-type=text/xml;charset=UTF-8, User-Agent=Jakarta Commons-HttpClient/3.1, breadcrumbId=ID-Anupam-PC-49990-1345051042099-0-2, CamelCxfMessage={org.apache.cxf.message.Message.PROTOCOL_HEADERS={accept-encoding=[gzip,deflate], Content-Length=[563], content-type=[text/xml;charset=UTF-8], Host=[localhost:9080], SOAPAction=["http://reportincident.example.camel.apache.org/ReportIncident"], User-Agent=[Jakarta Commons-HttpClient/3.1]}, HTTP_CONTEXT_MATCH_STRATEGY=stem, org.apache.cxf.request.url=http://localhost:9080/camel-example-cxf-proxy/webservices/ReportIncident, org.apache.cxf.request.uri=/camel-example-cxf-proxy/webservices/ReportIncident, HTTP.REQUEST=(POST /camel-example-cxf-proxy/webservices/ReportIncident)@2349183 org.eclipse.jetty.server.Request@23d87f, HTTP.CONFIG=null, org.apache.cxf.transport.https.CertConstraints=null, Accept=null, org.apache.cxf.message.Message.PATH_INFO=/camel-example-cxf-proxy/webservices/ReportIncident, org.apache.cxf.message.Message.BASE_PATH=/camel-example-cxf-proxy/webservices/ReportIncident, org.apache.cxf.continuations.ContinuationProvider=org.apache.cxf.transport.http_jetty.continuations.JettyContinuationProvider@15a9fdf, org.apache.cxf.message.Message.IN_INTERCEPTORS=[org.apache.cxf.transport.https.CertConstraintsInterceptor@b626b0], org.apache.cxf.binding.soap.SoapVersion=org.apache.cxf.binding.soap.Soap11@a61d64, org.apache.cxf.message.Message.ENCODING=UTF-8, org.apache.cxf.message.Message.QUERY_STRING=null, HTTP.RESPONSE=HTTP/1.1 200 , org.apache.cxf.security.SecurityContext=org.apache.cxf.transport.http.AbstractHTTPDestination$2@1d394ab, org.apache.cxf.request.method=POST, org.apache.cxf.async.post.response.dispatch=true, org.apache.cxf.configuration.security.AuthorizationPolicy=null, org.apache.cxf.message.MessageFIXED_PARAMETER_ORDER=false, org.apache.cxf.transport.Destination=org.apache.cxf.transport.http_jetty.JettyHTTPDestination@19318fa, http.base.path=http://localhost:9080/camel-example-cxf-proxy/webservices, Content-Type=text/xml;charset=UTF-8, HTTP.CONTEXT=ServletContext@o.e.j.s.h.ContextHandler{/camel-example-cxf-proxy/webservices,null}}}, BodyType:null, Body:[Body is instance of java.io.InputStream]]


For the purpose of having a test case I have attached a rar containing the entire project in my earlier post.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: exposing different operations under same service in camel + cxf routing.

anupamsen
This post has NOT been accepted by the mailing list yet.
Please post.

--- On Wed, 8/15/12, anupamsen [via Camel] <[hidden email]> wrote:

From: anupamsen [via Camel] <[hidden email]>
Subject: Re: exposing different operations under same service in camel + cxf routing.
To: "anupamsen" <[hidden email]>
Date: Wednesday, August 15, 2012, 10:55 PM

Following is the header that I see in the logs when run with "mvn camel:run" and routed to log uaing show header option like below-

<to uri="log:before?showHeaders=true"/>.

I don't see no operationName header -

Headers:{SOAPAction="http://reportincident.example.camel.apache.org/ReportIncident", accept-encoding=gzip,deflate, Host=localhost:9080, content-type=text/xml;charset=UTF-8, User-Agent=Jakarta Commons-HttpClient/3.1, breadcrumbId=ID-Anupam-PC-49990-1345051042099-0-2, CamelCxfMessage={org.apache.cxf.message.Message.PROTOCOL_HEADERS={accept-encoding=[gzip,deflate], Content-Length=[563], content-type=[text/xml;charset=UTF-8], Host=[localhost:9080], SOAPAction=["http://reportincident.example.camel.apache.org/ReportIncident"], User-Agent=[Jakarta Commons-HttpClient/3.1]}, HTTP_CONTEXT_MATCH_STRATEGY=stem, org.apache.cxf.request.url=http://localhost:9080/camel-example-cxf-proxy/webservices/ReportIncident, org.apache.cxf.request.uri=/camel-example-cxf-proxy/webservices/ReportIncident, HTTP.REQUEST=(POST /camel-example-cxf-proxy/webservices/ReportIncident)@2349183 org.eclipse.jetty.server.Request@23d87f, HTTP.CONFIG=null, org.apache.cxf.transport.https.CertConstraints=null, Accept=null, org.apache.cxf.message.Message.PATH_INFO=/camel-example-cxf-proxy/webservices/ReportIncident, org.apache.cxf.message.Message.BASE_PATH=/camel-example-cxf-proxy/webservices/ReportIncident, org.apache.cxf.continuations.ContinuationProvider=org.apache.cxf.transport.http_jetty.continuations.JettyContinuationProvider@15a9fdf, org.apache.cxf.message.Message.IN_INTERCEPTORS=[org.apache.cxf.transport.https.CertConstraintsInterceptor@b626b0], org.apache.cxf.binding.soap.SoapVersion=org.apache.cxf.binding.soap.Soap11@a61d64, org.apache.cxf.message.Message.ENCODING=UTF-8, org.apache.cxf.message.Message.QUERY_STRING=null, HTTP.RESPONSE=HTTP/1.1 200 , org.apache.cxf.security.SecurityContext=org.apache.cxf.transport.http.AbstractHTTPDestination$2@1d394ab, org.apache.cxf.request.method=POST, org.apache.cxf.async.post.response.dispatch=true, org.apache.cxf.configuration.security.AuthorizationPolicy=null, org.apache.cxf.message.MessageFIXED_PARAMETER_ORDER=false, org.apache.cxf.transport.Destination=org.apache.cxf.transport.http_jetty.JettyHTTPDestination@19318fa, http.base.path=http://localhost:9080/camel-example-cxf-proxy/webservices, Content-Type=text/xml;charset=UTF-8, HTTP.CONTEXT=[hidden email]{/camel-example-cxf-proxy/webservices,null}}}, BodyType:null, Body:[Body is instance of java.io.InputStream]]


For the purpose of having a test case I have attached a rar containing the entire project in my earlier post.



To unsubscribe from exposing different operations under same service in camel + cxf routing., click here.
NAML
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: exposing different operations under same service in camel + cxf routing.

anupamsen
In reply to this post by anupamsen
By the way I am calling the 2 operations in the WSDL using SOAPUI.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: exposing different operations under same service in camel + cxf routing.

anupamsen
My bad, I used the dataFormat as MESSAGE and it seems teh operation name is available only in case of dataFormat = PAYLOAD. It works for me with dataFormat = PAYLOAD.

Thanks.
Loading...