1 package org.apache.axis2.clientapi; 2 3 import org.apache.axis2.addressing.miheaders.RelatesTo; 4 import org.apache.axis2.context.MessageContext; 5 import org.apache.axis2.engine.AxisFault; 6 import org.apache.axis2.engine.MessageReceiver; 7 import org.apache.axis2.soap.SOAPEnvelope; 8 9 import java.util.HashMap ; 10 11 public class CallbackReceiver implements MessageReceiver { 12 13 public static String SERVIC_NAME = "ClientService"; 14 15 private HashMap callbackstore; 16 17 public CallbackReceiver() { 18 callbackstore = new HashMap (); 19 } 20 21 public void addCallback(String MsgID, Callback callback) { 22 callbackstore.put(MsgID, callback); 23 } 24 25 public void invoke(String MsgID, SOAPEnvelope result) { 26 27 } 28 31 public void recieve(MessageContext messgeCtx) throws AxisFault { 32 RelatesTo relatesTO = messgeCtx.getMessageInformationHeaders().getRelatesTo(); 34 35 String messageID = relatesTO.getValue(); 36 Callback callback = (Callback) callbackstore.get(messageID); 37 AsyncResult result = new AsyncResult(messgeCtx); 38 if (callback != null) { 39 callback.onComplete(result); 40 callback.setComplete(true); 41 }else{ 42 throw new AxisFault("The Callback realtes to MessageID "+ messageID + " is not found"); 43 } 44 } 45 46 } 47 | Popular Tags |