You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by James Carlyle <ja...@fableflow.com> on 2002/09/01 21:51:32 UTC

can handlers in a chain mutate the message? (newbie)

Hi

Just getting started with Axis.  I read in the example code that the log
handler (java:samples.userguide.example4.LogHandler) implements the 'invoke'
method of the BasicHandler class but does not change the content of the
message in it's context.

Can handlers change the Body payload of the message?  Could I do some XSLT
transformation on the payload in one handler before passing the context and
changed message on to the next handler in the chain?  Or can this only
happen in a handler which is the sole pivot point of the service?  Although
the Architecture guide states "a message is processed by passing through the
appropriate Chains. A message context is used to pass the message and
associated environment through the sequence of Handlers" it is not clear
what the intermediate handlers can do.

Many thanks if you can help.

James Carlyle

FableFlow : MMS templating and delivery
Multimedia Messaging commentary : http://www.fableflow.com/weblog/


RE: can handlers in a chain mutate the message? (newbie)

Posted by Ricky Ho <ri...@cisco.com>.
I think a handler shouldn't be aware of what other handler is behind him so 
skipping one is not what I want.  And I'm not looking for a sophisticated 
workflow for the execution sequence of message handler.  To that end, I 
think BPEL is addressing that.

What I need is the ability for a handler to return a response back to the 
client and shortcut the rest of the execution path.  Throwing an exception 
is not a good way because I want the client to be transparent (he should 
receive a normal response but not a SOAP fault).

Correct me if I'm wrong.  Although AXIS is providing a nice platform for 
the endpoint service provider, I don't think it provides a nice platform 
for the intermediaries.  By intermediary, I mean a piece of value added 
functionality that manipulate the SOAP message (processing some headers ... 
etc.) and then forward to the targeted endpoint (which lives in a different 
machine).  Maybe I'm just asking for a new type of pivot provider that 
forward the message to another endpoint.

Best regards,
Ricky

At 02:22 PM 9/9/2002 -0500, Allegar Robert wrote:
>Ricky,
>         I was actually thinking about how to short-cut the path .. if you 
> wanted to
>stop execution of the handler chain you can just throw an exception out of
>one of the handlers. If you wanted to "skip" one of the handlers you could
>create an Enumeration object or set some other static value in the Session
>and then test for it as part of the invoke() call. For example test to see
>if a certain value is present -- if so do something, if not do something
>else.
>
>         It would be interesting to see how this could work out into a 
> workflow
>mechanism for web services. Similar to a MVC architecture but multi-step
>rather than just the request-response flow. I'd bet that that stack-based
>handler architecture framework that Axis provides is flexible enough to do
>complex branching, error handling and other things. Just needs a little bit
>more architectural infrastructure.
>
>Rob
>
>-----Original Message-----
>From: Ricky Ho [mailto:riho@cisco.com]
>Sent: Monday, September 09, 2002 12:19 PM
>To: axis-user@xml.apache.org; axis-user@xml.apache.org
>Subject: RE: can handlers in a chain mutate the message? (newbie)
>
>
>Just be aware that the handler can do any modification to the message
>itself but CANNOT shortcut the path.  I have a hard time implementing a
>cache handler in AXIS.
>
>Rgds, Ricky
>
>At 12:55 PM 9/9/2002 -0500, Allegar Robert wrote:
> >James,
> >         A handler can do pretty much anything it wants to the entire
> > message. If
> >you want to change the body, you can. Same goes with the header. You can
> >even pass an entirely different message along if you want.
> >
> >         The LogHandler that's distributed as the example just shows how
> > to read the
> >content of the message. As you said, you could very easily do some XSLT or
> >other processing in the handler, set the changes on the message and then
>the
> >changed message would be passed along to the next handler in the chain (if
> >one exists). You don't need to explicitly call the next handler in the
>chain
> >(as you do in servlet chains) as the axis container will do that for you.
> >
> >         In general, you should probably try and keep your handlers as
> > discrete and
> >independent as possible. Look back a few days on this list and you'll see
> >some code posted that shows you how to modify the headers in the soap
> >message in the body of a handler.
> >
> >Regards,
> >         Rob
> >
> >-----Original Message-----
> >From: James Carlyle [mailto:james.carlyle@fableflow.com]
> >Sent: Sunday, September 01, 2002 2:52 PM
> >To: axis-user@xml.apache.org
> >Subject: can handlers in a chain mutate the message? (newbie)
> >
> >
> >Hi
> >
> >Just getting started with Axis.  I read in the example code that the log
> >handler (java:samples.userguide.example4.LogHandler) implements the
>'invoke'
> >method of the BasicHandler class but does not change the content of the
> >message in it's context.
> >
> >Can handlers change the Body payload of the message?  Could I do some XSLT
> >transformation on the payload in one handler before passing the context and
> >changed message on to the next handler in the chain?  Or can this only
> >happen in a handler which is the sole pivot point of the service?  Although
> >the Architecture guide states "a message is processed by passing through
>the
> >appropriate Chains. A message context is used to pass the message and
> >associated environment through the sequence of Handlers" it is not clear
> >what the intermediate handlers can do.
> >
> >Many thanks if you can help.
> >
> >James Carlyle
> >
> >FableFlow : MMS templating and delivery
> >Multimedia Messaging commentary : http://www.fableflow.com/weblog/


RE: can handlers in a chain mutate the message? (newbie)

Posted by Ricky Ho <ri...@cisco.com>.
Response inline.


>Do you mean that handler steps in the chain cannot be bypassed?

I mean the pivot point cannot be bypassed.  In the cache handler case, if 
the result is already found in cache, I want the request handler return the 
cache response to the client without passing on to the pivot point.


>Just thinking about the special nature of the pivot point, is the following
>true?
>There must be one and only one (not more or less) pivot points.  It would
>not be possible to go through one pivot point, set setPastPivot to false (on
>the MessageContext object), and then present another pivot point.

That's true.  As far as I understand, only the pivot handler is supposed to 
call the setPastPivot method.


> >From the examples, pivot handlers seem to be very closely tied to Java
>methods, as described in the WSDD document.  The examples demonstrate
>clearly how to deploy existing Java methods as web services, but not how to
>develop methods for existing SOAP formats.  Can I use a pivot handler to
>process a pre-specified SOAP message?

Yes, you can use the Messaging Provider of AXIS to achieve that.  In this 
case, your Java class only need to provide a method that takes a SOAP 
Message as an input parameter and return a SOAP Message.  Of course, you 
Java code is dealing with the XML message drectly.

Rgds, Ricky


RE: can handlers in a chain mutate the message? (newbie)

Posted by James Carlyle <ja...@fableflow.com>.
Ricky and Rob

Many thanks for your help.

> Just be aware that the handler can do any modification to the message
> itself but CANNOT shortcut the path.  I have a hard time implementing a
> cache handler in AXIS.

Do you mean that handler steps in the chain cannot be bypassed?

Just thinking about the special nature of the pivot point, is the following
true?
There must be one and only one (not more or less) pivot points.  It would
not be possible to go through one pivot point, set setPastPivot to false (on
the MessageContext object), and then present another pivot point.

>From the examples, pivot handlers seem to be very closely tied to Java
methods, as described in the WSDD document.  The examples demonstrate
clearly how to deploy existing Java methods as web services, but not how to
develop methods for existing SOAP formats.  Can I use a pivot handler to
process a pre-specified SOAP message?  For example, the following is an
example SOAP request for sending a multimedia message (MMS) (specified in
the MM7 interface) to the telecom operator's MMSC, snipped for brevity:

<?xml version="1.0" ?>
<env:Envelope xmlns:env="http:// schemas.xmlsoap.org/soap /soap-envelope">
      <env:Header>
		<mm7:TransactionID
xmlns:mm7="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL
-5-MM7-1-0" env:mustUnderstand="1">
			vas00001-sub
		</mm7:TransactionID>
	</env:Header>
	<env:Body>
		<mm7:SubmitReq
xmlns:mm7="http://www.3gpp.org/ftp/Specs/archive/23_series/23.140/schema/REL
-5-MM7-1-0">
			<MM7Version>5.3.0</MM7Version>
			<SenderIdentification>
				<VASPID>TNN</VASPID>
			</SenderIdentification>
			<Recipients>

<To><Number>7255441234</Number><RFC2822Address>7255442222@OMMS.com</RFC2822A
ddress></To>
			</Recipients>
			<Subject>News for today</Subject>
			<Content href="cid:SaturnPics-01020930@news.tnn.com";
allowAdaptations="True"/>
		</mm7:SubmitReq>
	</env:Body>
</env:Envelope>

If I was writing the server and received this message, how could I process
this in a pivot point mapped to a Java class?  In other words, if the
message structure is determined, but the class implementation is up to the
developer, is Axis suitable?

Sorry for my current comprehension gulf.  Apologies too if my terminology is
incorrect.

James Carlyle


RE: can handlers in a chain mutate the message? (newbie)

Posted by Allegar Robert <al...@bah.com>.
Ricky,
	I was actually thinking about how to short-cut the path .. if you wanted to
stop execution of the handler chain you can just throw an exception out of
one of the handlers. If you wanted to "skip" one of the handlers you could
create an Enumeration object or set some other static value in the Session
and then test for it as part of the invoke() call. For example test to see
if a certain value is present -- if so do something, if not do something
else.

	It would be interesting to see how this could work out into a workflow
mechanism for web services. Similar to a MVC architecture but multi-step
rather than just the request-response flow. I'd bet that that stack-based
handler architecture framework that Axis provides is flexible enough to do
complex branching, error handling and other things. Just needs a little bit
more architectural infrastructure.

Rob

-----Original Message-----
From: Ricky Ho [mailto:riho@cisco.com]
Sent: Monday, September 09, 2002 12:19 PM
To: axis-user@xml.apache.org; axis-user@xml.apache.org
Subject: RE: can handlers in a chain mutate the message? (newbie)


Just be aware that the handler can do any modification to the message
itself but CANNOT shortcut the path.  I have a hard time implementing a
cache handler in AXIS.

Rgds, Ricky

At 12:55 PM 9/9/2002 -0500, Allegar Robert wrote:
>James,
>         A handler can do pretty much anything it wants to the entire
> message. If
>you want to change the body, you can. Same goes with the header. You can
>even pass an entirely different message along if you want.
>
>         The LogHandler that's distributed as the example just shows how
> to read the
>content of the message. As you said, you could very easily do some XSLT or
>other processing in the handler, set the changes on the message and then
the
>changed message would be passed along to the next handler in the chain (if
>one exists). You don't need to explicitly call the next handler in the
chain
>(as you do in servlet chains) as the axis container will do that for you.
>
>         In general, you should probably try and keep your handlers as
> discrete and
>independent as possible. Look back a few days on this list and you'll see
>some code posted that shows you how to modify the headers in the soap
>message in the body of a handler.
>
>Regards,
>         Rob
>
>-----Original Message-----
>From: James Carlyle [mailto:james.carlyle@fableflow.com]
>Sent: Sunday, September 01, 2002 2:52 PM
>To: axis-user@xml.apache.org
>Subject: can handlers in a chain mutate the message? (newbie)
>
>
>Hi
>
>Just getting started with Axis.  I read in the example code that the log
>handler (java:samples.userguide.example4.LogHandler) implements the
'invoke'
>method of the BasicHandler class but does not change the content of the
>message in it's context.
>
>Can handlers change the Body payload of the message?  Could I do some XSLT
>transformation on the payload in one handler before passing the context and
>changed message on to the next handler in the chain?  Or can this only
>happen in a handler which is the sole pivot point of the service?  Although
>the Architecture guide states "a message is processed by passing through
the
>appropriate Chains. A message context is used to pass the message and
>associated environment through the sequence of Handlers" it is not clear
>what the intermediate handlers can do.
>
>Many thanks if you can help.
>
>James Carlyle
>
>FableFlow : MMS templating and delivery
>Multimedia Messaging commentary : http://www.fableflow.com/weblog/


RE: can handlers in a chain mutate the message? (newbie)

Posted by Ricky Ho <ri...@cisco.com>.
Just be aware that the handler can do any modification to the message 
itself but CANNOT shortcut the path.  I have a hard time implementing a 
cache handler in AXIS.

Rgds, Ricky

At 12:55 PM 9/9/2002 -0500, Allegar Robert wrote:
>James,
>         A handler can do pretty much anything it wants to the entire 
> message. If
>you want to change the body, you can. Same goes with the header. You can
>even pass an entirely different message along if you want.
>
>         The LogHandler that's distributed as the example just shows how 
> to read the
>content of the message. As you said, you could very easily do some XSLT or
>other processing in the handler, set the changes on the message and then the
>changed message would be passed along to the next handler in the chain (if
>one exists). You don't need to explicitly call the next handler in the chain
>(as you do in servlet chains) as the axis container will do that for you.
>
>         In general, you should probably try and keep your handlers as 
> discrete and
>independent as possible. Look back a few days on this list and you'll see
>some code posted that shows you how to modify the headers in the soap
>message in the body of a handler.
>
>Regards,
>         Rob
>
>-----Original Message-----
>From: James Carlyle [mailto:james.carlyle@fableflow.com]
>Sent: Sunday, September 01, 2002 2:52 PM
>To: axis-user@xml.apache.org
>Subject: can handlers in a chain mutate the message? (newbie)
>
>
>Hi
>
>Just getting started with Axis.  I read in the example code that the log
>handler (java:samples.userguide.example4.LogHandler) implements the 'invoke'
>method of the BasicHandler class but does not change the content of the
>message in it's context.
>
>Can handlers change the Body payload of the message?  Could I do some XSLT
>transformation on the payload in one handler before passing the context and
>changed message on to the next handler in the chain?  Or can this only
>happen in a handler which is the sole pivot point of the service?  Although
>the Architecture guide states "a message is processed by passing through the
>appropriate Chains. A message context is used to pass the message and
>associated environment through the sequence of Handlers" it is not clear
>what the intermediate handlers can do.
>
>Many thanks if you can help.
>
>James Carlyle
>
>FableFlow : MMS templating and delivery
>Multimedia Messaging commentary : http://www.fableflow.com/weblog/


RE: can handlers in a chain mutate the message? (newbie)

Posted by Allegar Robert <al...@bah.com>.
James,
	A handler can do pretty much anything it wants to the entire message. If
you want to change the body, you can. Same goes with the header. You can
even pass an entirely different message along if you want.

	The LogHandler that's distributed as the example just shows how to read the
content of the message. As you said, you could very easily do some XSLT or
other processing in the handler, set the changes on the message and then the
changed message would be passed along to the next handler in the chain (if
one exists). You don't need to explicitly call the next handler in the chain
(as you do in servlet chains) as the axis container will do that for you.

	In general, you should probably try and keep your handlers as discrete and
independent as possible. Look back a few days on this list and you'll see
some code posted that shows you how to modify the headers in the soap
message in the body of a handler.

Regards,
	Rob

-----Original Message-----
From: James Carlyle [mailto:james.carlyle@fableflow.com]
Sent: Sunday, September 01, 2002 2:52 PM
To: axis-user@xml.apache.org
Subject: can handlers in a chain mutate the message? (newbie)


Hi

Just getting started with Axis.  I read in the example code that the log
handler (java:samples.userguide.example4.LogHandler) implements the 'invoke'
method of the BasicHandler class but does not change the content of the
message in it's context.

Can handlers change the Body payload of the message?  Could I do some XSLT
transformation on the payload in one handler before passing the context and
changed message on to the next handler in the chain?  Or can this only
happen in a handler which is the sole pivot point of the service?  Although
the Architecture guide states "a message is processed by passing through the
appropriate Chains. A message context is used to pass the message and
associated environment through the sequence of Handlers" it is not clear
what the intermediate handlers can do.

Many thanks if you can help.

James Carlyle

FableFlow : MMS templating and delivery
Multimedia Messaging commentary : http://www.fableflow.com/weblog/