axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Merritt, Norris" <>
Subject Reusing an Axis2 OperationClient -- how, exactly?? Does anyone have a non-trivial OperationClient sample?
Date Wed, 26 Sep 2007 18:35:00 GMT
I have been trying without success to reuse an OperationClient to send
multiple messages without having to reconstruct the OperationClient,
ServiceClient, and related objects for each message transmission.  I am
pursuing this as part of an effort to get my client to reuse the same
HTTPS connection for multiple message exchanges, since I don't want the
overhead of SSL handshake on every exchange, and I can't see how I could
possibly accomplish this if I am building the OperationClient from
scratch for each message exchange. 


My OperationClient is patterned after the "" sample
I found here:


The sample works for multiple sends only if I execute all of the code
(recreate the entire client) for each SOAP message I send. But if I try
to send a second message with the same client, when I call execute( )  I
get an exception with the message "The message exchange pattern (MEP) is
already complete. Use the reset method before re-running."  


The OperationClient.reset() method Javadoc says:


ent.html#reset()> () 
          Reset the operation client to a clean status after the MEP has



OK, sounds reasonable, but if I call the reset() method on the
OperationClient immediately following a successful message exchange, the
next time I try to do a send, I get a java.lang.NullPointerException at
org.apache.axis2.description.OutInAxisOperationClient.getMessageContext( when I try to retrieve the MessageContext
to set the soap envelope in it for the next outgoing request:


      MessageContext msgCtx = operationClient.getMessageContext("Out");
<==== blows up here with NPE on second request if reset() was done


That line of code executed fine for the first send, so I assume that
reset() blows away the message context and I need to add a new one. So I
add a couple lines of code to create a new MessageContext and add it to
the OperationClient, exactly as I did before the first call, immediately
following the reset():




      MessageContext msgCtxNew = new MessageContext();

      operationClient.addMessageContext(msgCtxNew);          <==   Now
it blows up here with NPE


But this causes it to blow up on the operationClient.addMessageContext(
) call:







My guess is registerOperationContext is failing because of a null
OperationContext in mepContext:


    public boolean registerOperationContext(String messageID,

                                            OperationContext mepContext)

        boolean alreadyInMap;



So does the reset() operation blow away the OperationContext too?  Do I
have to construct one of these with some factory now, just because I
want to send a second message, when I didn't even have to know this
object existed to send the first message?  I really don't get this



View raw message