Syntax
C#
[OperationContractAttribute()] SBT.API.DataContracts.Admin.WSTemplateResponse CreateTemplate( string securityToken, SBT.API.DataContracts.Admin.TemplateDetail template )
WSDL
Production: https://ui.solutionsbytext.com/Sbt.App.SetUp/WSServices/templateWSService.svc?singleWsdl
Staging: https://test.solutionsbytext.com/Sbt.App.SetUp/WSServices/templateWSService.svc?singleWsdl
Parameters
securityToken
– String[1000] (Required) – SecurityToken to authenticate the user.
template
TemplateDetail – TemplateDetail object.
* Title – String[100] (Required) – Title of the template.
* Subject – String[100] (Required) – Subject of the template.
* Text – String[160] (Required) – Actual message of the template.
* Description – String[160] (Optional) – Add description or note of the template.
* OrgCode – String[20] (Required) – Default Organization Code for the group where template is to be created.
Return Value
WSTemplateResponse
| Name | Type | Description |
|---|---|---|
Result | bool | True/False whether the call was successful or not. |
ErrorCode | int | For Success/Failure it returns an error number. |
Message | string | Message related to the Error code. |
Response | TemplateDetail | TemplateDetail object. |
Examples
lblError.Text = "";
TemplateClient templateService = new TemplateClient("TemplateWSServiceHttpEndpoint");
string securityToken = txtToken.Text;
TemplateDetail templateDetail = new TemplateDetail();
templateDetail.Title = txtTitle.Text.Trim();
templateDetail.Subject = txtSubject.Text.Trim();
templateDetail.Text = txtText.Text.Trim();
templateDetail.Description = txtDescription.Text.Trim();
templateDetail.OrgCode = txtOrgCode.Text.Trim();
WSTemplateResponse wSTemplateResponse = templateService.CreateTemplate(securityToken, templateDetail);
if (!wSTemplateResponse.Result)
{
//handle error
lblError.Text = wSTemplateResponse.Message;
}
else
{
//handle success
lblError.Text = wSTemplateResponse.Message;
}
SOAP
Soap Request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://SBTService/ServiceContracts/" xmlns:ser1="http://schemas.microsoft.com/2003/10/Serialization/" xmlns:dat="http://SBTAPIService/DataContract/">
<soapenv:Header/>
<soapenv:Body>
<ser:CreateTemplate>
<!--Required:-->
<ser:securityToken>Security Token </ser:securityToken>
<ser:template>
<!--Optional:-->
<dat:TemplateID>Can be empty</dat:TemplateID>
<!--Required:-->
<dat:Title>Title of Template</dat:Title>
<!--Required:-->
<dat:Subject>Subject of Template</dat:Subject>
<!--Required:-->
<dat:Text>Content of the template </dat:Text>
<!--Optional:-->
<dat:Description>Description of Template</dat:Description>
<!--Required:-->
<dat:OrgCode>Group Org Code where template to be created</dat:OrgCode>
</ser:template>
</ser:CreateTemplate>
</soapenv:Body>
</soapenv:Envelope>
Soap Response
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<CreateTemplateResponse xmlns="http://SBTService/ServiceContracts/">
<CreateTemplateResult z:Id="i1" xmlns:a="http://SBTAPIService/DataContract/" xmlns:i=http://www.w3.org/2001/XMLSchema-instance xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/">
<a:Result>true</a:Result>
<a:ErrorCode>1007</a:ErrorCode>
<a:Message>Template created successfully</a:Message>
<a:Response z:Id="i2">
<a:TemplateID>Generated unique template ID</a:TemplateID>
<a:Title>Title of Template</a:Title>
<a:Subject>Subject of Template</a:Subject>
<a:Text>Content of the template</a:Text>
<a:Description>Template Description</a:Description>
</a:Response>
</CreateTemplateResult>
</CreateTemplateResponse>
</s:Body>
</s:Envelope>
JAVA
TemplateWSService srv = new TemplateWSService();
ITemplate iTemplate = srv.getTemplateWSServiceHttpEndpoint1();
WSTemplateResponse res = null;
String securityToken = "securityToken";
TemplateDetail template = new TemplateDetail();
template.setTitle(new JAXBElement(new QName("http://SBTAPIService/DataContract/", "Title"),
new String("").getClass(),"Test-1"));
template.setSubject(new JAXBElement(new QName("http://SBTAPIService/DataContract/", "Subject"),
new String("").getClass(),"Test"));
template.setText(new JAXBElement(new QName("http://SBTAPIService/DataContract/", "Text"),
new String("").getClass(),"This is a test template"));
template.setDescription(new< JAXBElement(new QName("http://SBTAPIService/DataContract/", "Description"),
new String("").getClass(),"Remarks"));
template.setOrgCode(new JAXBElement(new QName("http://SBTAPIService/DataContract/", "OrgCode"),
new String("").getClass(),"OrgCode"));
try {
res = iTemplate.createTemplate(securityToken, template);
} catch (Throwable e) {
e.printStackTrace();
}
if(res == null ){
System.out.println("::Erron::");
return;
}
if (res.isResult() == null< || !res.isResult())
{
//handle error
System.out.println("ErrorCode::"+res.getErrorCode());
System.out.println("ErrorMessage::"+res.getMessage().getValue());
}
else
{
//handle success
System.out.println("ID::"+res.getId());
System.out.println("Message::"+res.getMessage().getValue());
}
PHP
<?php
$client = new SoapClient("https://ui.solutionsbytext.com/Sbt.App.SetUp/wsservices/templateWSService.svc?wsdl");
$param = array(
'securityToken' =--> 'securityToken',
'template' => array(
'Title' => 'Test1-1',
'Subject' => 'Test',
'Text' => 'This is a test template',
'Description' => 'Remarks',
'OrgCode' => 'OrgCode'
)
);
$response = $client->__soapCall('CreateTemplate', array($param));
echo '<pre?>';
print_r($response);
if($response->CreateTemplateResult->Result){
echo 'Message: '.$response->CreateTemplateResult->Message;
}
else {
echo 'Message: '.$response->CreateTemplateResult->Message;
}
?>
REST
Method: POST
URL: https://ui.solutionsbytext.com/SBT.App.SetUp/RSServices/TemplateRSService.svc/CreateTemplate
Sample C# Code:
TemplateDetail tempDetail = new TemplateDetail
{
TemplateID = 123,
Title = "Title",
Subject = "Subject",
Text = "Text",
Description = "Description",
OrgCode = "OrgCode"
};
DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(SubscriberDetails));
MemoryStream mem = new MemoryStream();
ser.WriteObject(mem, tempDetail);
string data = Encoding.UTF8.GetString(mem.ToArray(), 0, (int)mem.Length);
var requestdata = new
{
securityToken = "securityToken",
template = tempDetail
};
string data2 = JsonConvert.SerializeObject(requestdata).ToString();
System.Net.WebClient webClient = new System.Net.WebClient();
webClient.Headers["Content-type"] = "application/json";
webClient.Encoding = Encoding.UTF8;
var strCreateTemplate = webClient.UploadString("https://ui.solutionsbytext.com/SBT.App.SetUp/RSServices/TemplateRSService.svc/CreateTemplate", "POST", data2);
Note:“strCreateTemplate” contains the output response as return values
Response:
The response will be in JSON format like below:
{" CreateTemplateResult": {
"result": true,
"error_code": 1007,
"Message": " Template Created succesfully",
“Response”: { “TemplateDetail response –
Template response Information will display” }
}}