You might be pleasantly surprised by Synapse.  With just a small amount of XML 
you could get the forwarding accomplished.  It also supports script languages 
right in the configuration, so you could do your pre-processing as well.  From 
the Synapse samples, here is a Synapse configuration that uses a script 
mediator component and a JavaScript function to pre-process and forward a 
message:


<!-- Introduction to the script mediator using js scripts -->
<definitions xmlns="http://ws.apache.org/ns/synapse";>
    <localEntry key="stockquoteScript" 
src="file:repository/conf/sample/resources/script/stockquoteTransform.js"/>

    <in>
        <!-- transform the custom quote request into a standard quote request 
expected by the service -->
        <script language="js" key="stockquoteScript" 
function="transformRequest"/>
        <send>
            <endpoint>
                <address 
uri="http://localhost:9000/soap/SimpleStockQuoteService"/>
            </endpoint>
        </send>
    </in>
    <out>
        <!-- transform the standard response back into the custom format the 
client expects -->
        <script language="js" key="stockquoteScript" 
function="transformResponse"/>
        <send/>
    </out>
</definitions>


Here is the JavaScript:


function transformRequest(mc) {
     var symbol = mc.getPayloadXML()..*::Code.toString();
     mc.setPayloadXML(
        <m:getQuote xmlns:m="http://services.samples/xsd";>
           <m:request>
              <m:symbol>{symbol}</m:symbol>
           </m:request>
        </m:getQuote>);
  }

  function transformResponse(mc) {
     var symbol = mc.getPayloadXML()..*::symbol.toString();
     var price = mc.getPayloadXML()..*::last.toString();
     mc.setPayloadXML(
        <m:CheckPriceResponse xmlns:m="http://services.samples/xsd";>
           <m:Code>{symbol}</m:Code>
           <m:Price>{price}</m:Price>
        </m:CheckPriceResponse>);
  }

-----Original Message-----
From: Jens Rutschmann [mailto:[email protected]]
Sent: Wednesday, June 17, 2009 4:23 PM
To: [email protected]
Subject: Re: Axis2: map generic method to multiple operations in service.xml

Caristi, Joe schrieb am 17.06.2009 21:33:
> You need: "a component that forwards the client's request to another web 
> service"
>
> This sounds like an Enterprise Service Bus!  Check out Apache Synapse -
>
> http://synapse.apache.org/

Thanks for your response.

I think an ESB is a bit too much and bit too little in my case :-)

I don't need as much capabilities as an ESB provides but I do need some custom
code inside the forwarding component which is run before forwarding the request.

Implementing this inside an ESB is probably more effort than implementing it
using Axis and I don't need the additional capabilities of an ESB in this
specific case.

Best regards,
Jens

>
>
> -----Original Message-----
> From: Jens Rutschmann [mailto:[email protected]]
> Sent: Wednesday, June 17, 2009 10:35 AM
> To: [email protected]
> Subject: Axis2: map generic method to multiple operations in service.xml
>
> Hi all,
>
> I'm looking for a way to reuse a generic java method for multiple web service
> operations. The reason for this is that I need to create a component that
> forwards the client's request to another web service. Since the additional 
> steps
> this component needs to do are always the same I'd like to use a single 
> generic
> implementation using AXIOM.
>
> In service.xml when defining an operation I can only specify the name of
> existing methods in the service class. Is there any way to map an arbitrary 
> name
> to a single method multiple times?
>
> I'd like to avoid creating new classes with stub methods that call the generic
> method since that would mean compiling and deploying of new code at runtime.
>
>
> Best regards any many thanks in advance,
> Jens
>
> STATEMENT OF CONFIDENTIALITY:
>
>
>
> The information contained in this electronic message and any attachments to
> this message are intended for the exclusive use of the addressee(s) and may
> contain confidential or privileged information. If you are not the intended
> recipient, please notify WHI Solutions immediately at [email protected],
> and destroy all copies of this message and any attachments.


STATEMENT OF CONFIDENTIALITY:



The information contained in this electronic message and any attachments to
this message are intended for the exclusive use of the addressee(s) and may
contain confidential or privileged information. If you are not the intended
recipient, please notify WHI Solutions immediately at [email protected],
and destroy all copies of this message and any attachments.

Reply via email to