1 16 package sample.amazon.amazonSimpleQueueService; 17 18 import org.apache.axis2.om.OMAbstractFactory; 19 import org.apache.axis2.om.OMElement; 20 import org.apache.axis2.om.OMNamespace; 21 import org.apache.axis2.soap.SOAPFactory; 22 23 29 public class OMElementCreator { 30 public static OMElement creatQueueElement(String createQueueElement, String key) { 31 SOAPFactory factory = OMAbstractFactory.getSOAP11Factory(); 32 OMNamespace opN = factory.createOMNamespace( 33 "http://webservices.amazon.com/AWSSimpleQueueService/2005-01-01", "nsQ"); 34 OMElement createQueue = factory.createOMElement("CreateQueue", opN); 35 OMElement subID = factory.createOMElement("SubscriptionId", opN); 36 OMElement request = factory.createOMElement("Request", opN); 37 OMElement queueName = factory.createOMElement("QueueName", opN); 38 OMElement readLockTimeOutSeconds = factory.createOMElement("ReadLockTimeoutSeconds", opN); 39 request.addChild(queueName); 40 request.addChild(readLockTimeOutSeconds); 41 subID.addChild(factory.createText(key)); 42 queueName.addChild(factory.createText(createQueueElement)); 43 readLockTimeOutSeconds.addChild(factory.createText("10")); 44 createQueue.addChild(subID); 45 createQueue.addChild(request); 46 return createQueue; 47 } 48 public static OMElement deleteQueueElement(String deleteQueueName, String key) { 49 SOAPFactory factory = OMAbstractFactory.getSOAP11Factory(); 50 OMNamespace opN = factory.createOMNamespace( 51 "http://webservices.amazon.com/AWSSimpleQueueService/2005-01-01", "nsQ"); 52 OMElement enque = factory.createOMElement("DeleteQueue", opN); 53 OMElement subID = factory.createOMElement("SubscriptionId", opN); 54 OMElement request = factory.createOMElement("Request", opN); 55 OMElement queueName = factory.createOMElement("QueueName", opN); 56 request.addChild(queueName); 58 subID.addChild(factory.createText(key)); 60 queueName.addChild(factory.createText(deleteQueueName)); 61 enque.addChild(subID); 63 enque.addChild(request); 64 return enque; 65 } 66 public static OMElement enqueueElement(String queueEntyBody, String queueIden, String key) { 67 SOAPFactory factory = OMAbstractFactory.getSOAP11Factory(); 68 OMNamespace opN = factory.createOMNamespace( 69 "http://webservices.amazon.com/AWSSimpleQueueService/2005-01-01", "nsQ"); 70 OMElement enque = factory.createOMElement("Enqueue", opN); 71 OMElement subID = factory.createOMElement("SubscriptionId", opN); 72 OMElement request = factory.createOMElement("Request", opN); 73 OMElement queueID = factory.createOMElement("QueueId", opN); 75 OMElement queueEntryBodies = factory.createOMElement("QueueEntryBodies", opN); 76 OMElement queueEntryBody1 = factory.createOMElement("QueueEntryBody", opN); 77 queueEntryBodies.addChild(queueEntryBody1); 78 request.addChild(queueID); 80 request.addChild(queueEntryBodies); 81 subID.addChild(factory.createText(key)); 82 queueID.addChild(factory.createText(queueIden)); 84 queueEntryBody1.addChild(factory.createText(queueEntyBody)); 85 enque.addChild(subID); 86 enque.addChild(request); 87 return enque; 88 } 89 public static OMElement queueListElement(String key) { 90 SOAPFactory factory = OMAbstractFactory.getSOAP11Factory(); 91 OMNamespace opN = factory.createOMNamespace( 92 "http://webservices.amazon.com/AWSSimpleQueueService/2005-01-01", 93 "nsQ"); 94 OMElement listMyQueues = factory.createOMElement("ListMyQueues", opN); 95 OMElement subID = factory.createOMElement("SubscriptionId", opN); 96 OMElement request = factory.createOMElement("Request", opN); 97 subID.addChild(factory.createText(key)); 98 listMyQueues.addChild(subID); 99 listMyQueues.addChild(request); 100 return listMyQueues; 101 } 102 public static OMElement read(String requiredQueueName,String key) { 103 SOAPFactory factory = OMAbstractFactory.getSOAP11Factory(); 104 OMNamespace opN = factory.createOMNamespace( 105 "http://webservices.amazon.com/AWSSimpleQueueService/2005-01-01", "nsQ"); 106 OMElement read = factory.createOMElement("Read", opN); 107 OMElement subID = factory.createOMElement("SubscriptionId", opN); 108 OMElement request = factory.createOMElement("Request", opN); 109 OMElement queueName = factory.createOMElement("QueueName", opN); 110 OMElement readCount = factory.createOMElement("ReadCount", opN); 112 request.addChild(queueName); 113 request.addChild(readCount); 115 subID.addChild(factory.createText(key)); 116 queueName.addChild(factory.createText(requiredQueueName)); 117 readCount.addChild(factory.createText("25")); 119 read.addChild(subID); 120 read.addChild(request); 121 return read; 122 } 123 } 124 | Popular Tags |