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 "Spies, Brennan" <Br...@ejgallo.com> on 2006/09/07 21:17:06 UTC

[Axis2] How to write server-side implementation for doc/lit

I have a (simple) question regarding the implementation of the server-side
logic web service in Axis 2.0, which is not clear from the documentation. 

 

After doing the code generation (doc/literal service with XMLBeans
databinding, and server-side interface), I am left with a MessageReceiver (in
my case AbstractInOutSyncMessageReceiver) which calls the skeleton's business
method from its invokeBusinessLogic() method. The generated business method
always has a method signature like: void name(). What I want to do, since I
am using a document-style service, is parse the body of the incoming message
using the *Document.Factory.parse() of the appropriate XMLBeans generated
class. 

 

2 options stand out:

 

1)       Change the method signature of my skeleton's invoked message so that
it passes in the appropriate MessageContext. Get the SOAP body from it,
retrieve the stream and parse.

2)       Add the following to the skeleton:

 

      private MessageContext msgCtx;

      

    public void setOperationContext(OperationContext opContext)  throws
AxisFault {

        this.msgCtx =
opContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);

    }

 

This, apparently, gets invoked by reflection during this operation:

 

                  org.apache.axis2.engine.DependencyManager

                              .configureBusinessLogicProvider(obj, msgContext

                                       .getOperationContext());

 

Does it make a difference (or is there a preferred way of doing this)? Is
there an easier way of wiring this that I am unaware of?

 

Presumably, you would use the MessageContext to get the SOAPBody, from which
you could parse using the appropriate XmlObject, like so:

 

            // Todo fill this with the necessary business logic

            SOAPBody body = msgCtx.getEnvelope().getBody();

            try {

                  ResultDocument rd =
ResultDocument.Factory.parse(body.getXMLStreamReader());

                  //etc...

            } catch (XmlException e) {

                  e.printStackTrace();

         }