CancelMessage

From CDYNE Wiki
Jump to navigation Jump to search

This method uses the Message ID to cancel a message scheduled for a later time or date. Does not work if message was already sent out or queued.

CancelMessage Request

Parameter Name Data Type Sample Input
MessageID: Input unique Guid ID that is returned with every SMS message sent. Guid B01d89fd-5155-5455-5585-e84ab8de8591

HTTP Method

HTTP Method: GET

Url: http://sms2.cdyne.com/sms.svc/CancelMessage?MessageID={MESSAGEID}

Url: https://sms2.cdyne.com/sms.svc/CancelMessage?MessageID={MESSAGEID}

CancelMessage Response

Parameter Name Data Type Sample Output
Returns a True or False value String False

XML Response

The following is an example response Xml body:


<boolean xmlns="http://schemas.microsoft.com/2003/10/Serialization/">true</boolean>

Json Response

The following is an example response Json body:


true

CancelMessage Code Examples

C#

1 IsmsClient client = new IsmsClient("sms2wsHttpBinding");
2 bool resp = client.CancelMessage(new Guid("MESSAGE ID HERE"));
3 bool Success = true;
4 if (Success == true)
5 {
6 Console.WriteLine("Message successfully cancelled.");
7 }
8 Console.ReadLine();
9 client.Close();

VB.NET

 1 Imports CancelMessage.WSDL
 2 Module Module1
 3  Sub Main()
 4  Dim client As New CancelMessage.WSDL.IsmsClient("sms2wsHttpBinding")
 5  Dim resp As Boolean = client.CancelMessage(New Guid("MESSAGE ID HERE"))
 6  Dim Success As Boolean = True
 7  If Success = True Then
 8  Console.WriteLine("Message successfully cancelled.")
 9  End If
10  Console.ReadLine()
11  client.Close()
12  End Sub
13 End Module

PHP

Returns a 1 if the SMS is canceled and nothing if it is not cancelled.

1 $client = new SoapClient('http://sms2.cdyne.com/sms.svc?wsdl');  
2  
3 $param = array('MessageID' => 'Message ID'//MessageID from SMSResponse Object
4 );
5 
6 $result = $client->CancelMessage($param);
7 
8 print_r($result);

PHP with cURL

 1 $url='http://sms2.cdyne.com/sms.svc/CancelMessage?MessageID=(Message ID)';
 2 
 3 $cURL = curl_init();
 4 
 5 curl_setopt($cURL,CURLOPT_URL,$url);
 6 curl_setopt($cURL,CURLOPT_HTTPGET,true);
 7 curl_setopt($cURL, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Accept: application/json'));
 8 
 9 $result = curl_exec($cURL);
10 
11 curl_close($cURL);
12 
13 print_r($result);

VBScript

1 Dim oXMLHTTP
2 Set oXMLHTTP = CreateObject("Microsoft.XMLHTTP")
3 Set oDoc = CreateObject("MSXML2.DOMDocument")
4 Call oXMLHttp.Open("GET", "http://sms2.cdyne.com/sms.svc/CancelMessage?MessageID=MESSAGE ID HERE", False)
5 Call oXMLHttp.setRequestHeader("Content-Type", "text/xml")
6 Call oXMLHttp.send
7 MsgBox oXMLHTTP.responseText

Ruby

1 require 'net/http'
2 require 'URI' 
3 puts URI.methods 
4 url = URI.parse('http://sms2.cdyne.com/sms.svc/CancelMessage?MessageID=MESSAGE ID HERE')
5 res = Net::HTTP.get_response(url) 
6 data = res.body 
7 puts data
8 gets data

JAVA

 1 import java.io.ByteArrayOutputStream;
 2 import java.io.InputStream;
 3 import java.net.URL;
 4 import java.net.MalformedURLException;
 5 import java.util.Properties; 
 6 import javax.xml.transform.OutputKeys;
 7 import javax.xml.transform.Source;
 8 import javax.xml.transform.Transformer;
 9 import javax.xml.transform.TransformerFactory;
10 import javax.xml.transform.stream.StreamResult;
11 import javax.xml.transform.stream.StreamSource;
12 
13 public final class CancelMessage{     
14 	public static void main(String[] args) { 	
15 	
16 			try{		
17 				URL url = new URL("http://sms2.cdyne.com/sms.svc/CancelMessage?"
18                                         + "MessageID=MESSAGEID OF MESSAGE YOU WANT TO CANCEL");		
19 			try{			
20 			InputStream in = url.openStream(); 
21 			StreamSource source = new StreamSource(in); 			
22 			printResult(source);	
23 		}catch(java.io.IOException e){			
24 			e.printStackTrace();		
25 		}		
26 		}catch (MalformedURLException e){		
27 			e.printStackTrace();	
28 				}     
29 			}     
30 			private static void printResult(Source source) {        
31 				try {            
32 				ByteArrayOutputStream bos = new ByteArrayOutputStream();
33 				StreamResult sr = new StreamResult(bos);
34                               
35 				Transformer trans = TransformerFactory.newInstance().newTransformer();
36 				Properties oprops = new Properties();
37 				oprops.put(OutputKeys.OMIT_XML_DECLARATION, "yes");
38 				trans.setOutputProperties(oprops);
39 				trans.transform(source, sr);            
40 				System.out.println("**** Response ******"); 
41                              
42                                 System.out.println(bos.toString());
43                                 
44                                 bos.close();
45                                 System.out.println();        
46 			} catch (Exception e) {            
47 				}    
48 			}
49 		}