package smssample; import java.math.BigDecimal; /** * * @author thuneke */ public class SMSSample { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here // TODO code application logic here com.easylink.ws.jobsubmit._2011._01.JobSubmitRequest req = null; com.easylink.ws.jobsubmit._2011._01.Request requestHeader = null; javax.xml.ws.Holder responseParameter = null; javax.xml.ws.Holder responseHeader = null; try { req = new com.easylink.ws.jobsubmit._2011._01.JobSubmitRequest(); requestHeader = new com.easylink.ws.jobsubmit._2011._01.Request(); com.easylink.ws.jobsubmit._2011._01.JobSubmitService service = new com.easylink.ws.jobsubmit._2011._01.JobSubmitService(); com.easylink.ws.jobsubmit._2011._01.JobSubmitPortType port = service.getJobSubmitPort(); // TODO initialize WS operation arguments here // // Authentication // com.easylink.ws.jobsubmit._2011._01.Request.Authentication auth = new com.easylink.ws.jobsubmit._2011._01.Request.Authentication(); com.easylink.ws.jobsubmit._2011._01.XDDSAuthType xauth = new com.easylink.ws.jobsubmit._2011._01.XDDSAuthType(); com.easylink.ws.jobsubmit._2011._01.UIDType uid = new com.easylink.ws.jobsubmit._2011._01.UIDType(); uid.setValue("userid"); xauth.setRequesterID(uid); xauth.setPassword("password"); auth.setXDDSAuth(xauth); requestHeader.setAuthentication(auth); requestHeader.setReceiverKey("https://test2messaging.easylink.com"); // // Document(s) // com.easylink.ws.jobsubmit._2011._01.DocDataType data = new com.easylink.ws.jobsubmit._2011._01.DocDataType(); data.setFormat(com.easylink.ws.jobsubmit._2011._01.DocEncodingFormat.TEXT); data.setValue("This is a test."); com.easylink.ws.jobsubmit._2011._01.DocumentType doc = new com.easylink.ws.jobsubmit._2011._01.DocumentType(); doc.setDocType("text"); doc.setDocData(data); doc.setRef("test"); doc.setFilename(new com.easylink.ws.jobsubmit._2011._01.EncodableStringType()); doc.getFilename().setValue("test.txt"); // not sure about the get first com.easylink.ws.jobsubmit._2011._01.DocumentSetType docSet = new com.easylink.ws.jobsubmit._2011._01.DocumentSetType(); docSet.getDocument().add(doc); req.setDocumentSet(docSet); // // Message(s) // com.easylink.ws.jobsubmit._2011._01.MessageType msg = new com.easylink.ws.jobsubmit._2011._01.MessageType(); com.easylink.ws.jobsubmit._2011._01.ContentsType contents = new com.easylink.ws.jobsubmit._2011._01.ContentsType(); com.easylink.ws.jobsubmit._2011._01.ContentPartType part = new com.easylink.ws.jobsubmit._2011._01.ContentPartType(); part.setDocRef("test"); part.setTreatment(com.easylink.ws.jobsubmit._2011._01.TreatmentType.BODY); contents.getPart().add(part); msg.setContents(contents); com.easylink.ws.jobsubmit._2011._01.JobOptionsType jobOptions = new com.easylink.ws.jobsubmit._2011._01.JobOptionsType(); com.easylink.ws.jobsubmit._2011._01.SmsOptionsType smsOptions = new com.easylink.ws.jobsubmit._2011._01.SmsOptionsType(); jobOptions.setBillingCode(new com.easylink.ws.jobsubmit._2011._01.EncodableStringType()); jobOptions.getBillingCode().setValue("BC12345"); jobOptions.setCustomerReference(new com.easylink.ws.jobsubmit._2011._01.EncodableStringType()); jobOptions.getCustomerReference().setValue("CREF1234"); smsOptions.setExpirationDays(BigDecimal.TEN); jobOptions.setSmsOptions(smsOptions); msg.setJobOptions(jobOptions); com.easylink.ws.jobsubmit._2011._01.SmsType sms = new com.easylink.ws.jobsubmit._2011._01.SmsType(); sms.setPhone("9543668330"); sms.setRef("Tom"); msg.setDestinations(new com.easylink.ws.jobsubmit._2011._01.DeliveryItemListType()); msg.getDestinations().getListOrSmQueryOrTable().add(sms); req.getMessage().add(msg); responseParameter = new javax.xml.ws.Holder(); responseHeader = new javax.xml.ws.Holder(); javax.xml.ws.BindingProvider bp = (javax.xml.ws.BindingProvider) port; bp.getRequestContext().put(javax.xml.ws.BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "https://test2messaging.easylink.com/soap/sync"); port.jobSubmit(req, requestHeader, responseParameter, responseHeader); // Check Status code of the result if(responseParameter.value != null) { int StatusCode = responseParameter.value.getStatus().getStatusCode().intValue(); java.util.List msgResultList = responseParameter.value.getMessageResult(); java.util.ListIterator msgResultIter = msgResultList.listIterator(); String domain = null; String jobNumber = null; while (msgResultIter.hasNext()) { com.easylink.ws.jobsubmit._2011._01.MessageResultType msgResult = msgResultIter.next(); com.easylink.ws.jobsubmit._2011._01.JobIdType jobId = msgResult.getJobId(); domain = jobId.getXDN(); jobNumber = jobId.getMRN().toString(); } String processingID; if (StatusCode == 0) { // StatusCode 0 = JobSubmit Successful processingID = responseHeader.value.getProcessingID(); } else { // JobSubmit Error (Display error in MsgBox) String sError = responseParameter.value.getStatus().getStatusCode().toString(); sError += "\n" + responseParameter.value.getStatus().getStatusMessage(); } } } catch (Exception ex) { ex.printStackTrace(); return; } catch (Throwable t) { t.printStackTrace(); return; } System.out.println(responseParameter.value.getStatus().getStatusCode().toString()); //if(responseParameter.value.getStatus().) } }