1 16 package sample.amazon.amazonSimpleQueueService.util; 17 18 import org.apache.axis2.clientapi.AsyncResult; 19 import org.apache.axis2.clientapi.Callback; 20 import org.apache.axis2.om.OMElement; 21 import org.apache.axis2.om.OMNode; 22 import org.apache.axis2.soap.SOAPBody; 23 24 import javax.swing.*; 25 import java.util.Iterator ; 26 31 public class SimpleQueueReadCallbackHandler extends Callback { 32 private String returnString = ""; 33 JTextField queueCode; 34 JTextArea results; 35 public SimpleQueueReadCallbackHandler(){} public SimpleQueueReadCallbackHandler(JTextField queueCode, JTextArea results){ 37 super(); 38 this.queueCode = queueCode; 39 this.results = results; 40 } 41 public void onComplete(AsyncResult result) { 42 SOAPBody body = result.getResponseEnvelope().getBody(); 43 this.getQueueEntryBody(body); 44 } 45 public void reportError(Exception e) { 46 47 } 48 private void getQueueEntryBody(OMElement element) { 49 Iterator iterator = element.getChildren(); 50 while (iterator.hasNext()) { 51 OMNode omNode = (OMNode) iterator.next(); 52 if (omNode.getType() == OMNode.ELEMENT_NODE) { 53 OMElement omElement = (OMElement) omNode; 54 if (omElement.getLocalName().equals("QueueEntryBody")) { 55 this.readTheQueue(omElement); 56 }else{ 57 getQueueEntryBody(omElement); 58 } 59 } 60 } 61 } 62 private void readTheQueue(OMElement element) { 63 returnString = returnString + element.getText() + "\n"; 64 this.results.setText(returnString + "\n"); 65 } 66 } 67 | Popular Tags |