DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Curious about the future of data-driven systems? Join our Data Engineering roundtable and learn how to build scalable data platforms.

Data Engineering: The industry has come a long way from organizing unstructured data to adopting today's modern data pipelines. See how.

Threat Detection: Learn core practices for managing security risks and vulnerabilities in your organization — don't regret those threats!

Managing API integrations: Assess your use case and needs — plus learn patterns for the design, build, and maintenance of your integrations.

Related

  • Enhance Your Communication Strategy: Deliver Multimedia Messages With AWS Pinpoint
  • What Is Artificially Inflated Traffic?
  • Revolutionizing Customer Engagement: Unleashing the Magic of Communication APIs
  • Supercharge Your Communication With Twilio and Ballerina

Trending

  • Multimodal RAG Is Not Scary, Ghosts Are Scary
  • Integrated Gradients: AI Explainability for Regulated Industries
  • Enhancing Observability in iOS Applications: Key Insights
  • Dapr and Service Meshes: Better Together

Sending Concatenated SMS with UDH using kannel

By 
Kirti Mandwade user avatar
Kirti Mandwade
·
Jun. 24, 15 · Code Snippet
Likes (1)
Comment
Save
Tweet
Share
6.8K Views

Join the DZone community and get the full member experience.

Join For Free
 
A normal SMS can contain upto 160 characters in GSM 7bit encoding.
For sending long messages that have more then 160 characters that message has to be splitted in multiple SMS with a UDH header added to them and sent one by one.
Whats a  UDH:

UDH - User Data Header
It keeps the information about the message.
UDH is made up of 6 parts:

05 - This tells the length of UDH which is 5 bytes(total bytes fllowing this byte).
00 - IEL (Information Element Identifier). This indicates that this message is concatenated. This value will remain same
03 - This tells the length of incoming information field (ie more three bytes will be there in UDH).
AA- This is unique identifier of message.It remains same for all parts of message. It can be any unique byte. For eg F3
BB- This tells the total number of message parts. For example If you have a long message divided in  two parts then this will be : 02
CC - The sequence number of this message. For example if you are sending first part of message then it will become 01 , if you are sending second part it will be 02.
So whole UDH will look like
Example UDH  : 050003F30201

Sending A message with udh
As UDH is in hexadecimal format, while sending message with UDH then text should also be converted to hex format.
The code snippet shows simple example to send Message with UDH using XML POST in kannel




public class kannelSend{

public static void sendMessage(String inputXMLConnect) throws IOException {
		 String url = "http://localhost:13003/cgi-bin/sendsms";  

		CloseableHttpClient httpClient = HttpClients.createDefault();
		HttpPost httpPost = null;
		CloseableHttpResponse response = null;
		InputStream in;
		StringEntity entity = null;

		entity = new StringEntity(inputXMLConnect, ContentType.create(
				"text/xml"));
		entity.setChunked(true);

		try {
			httpPost = new HttpPost(url);

			httpPost.setEntity(entity);
			
			
			response = httpClient.execute(httpPost);

			

			LOG.info(response.getStatusLine());
			in = response.getEntity().getContent();
			String body = IOUtils.toString(in);

				EntityUtils.consume(entity);
		} catch (Exception e) {
			LOG.error(e.getMessage(), e);

		}
		finally{
			response.close();

			httpClient.close();
		}


public static void main(String[] args) throws IOException {
	 String inputXMLConnect = "0000001234496e207468652063656c6c756c61722070686f6e6520696e6475737472792c206d6f62696c652070686f6e657320616e64207468656972206e6574776f726b7320736f6d6574696d657320737570706f727420636f6e636174656e617465642073686f7274206d657373616765207365727669636520746f206f766572636f6d6520746865206c696d69746174696f6e206f6e20746865206e050003F202016031abc123send";


	 
	 
	 submitKannelMessage(inputXMLConnect);
	 
	 inputXMLConnect = "00000123756d626572206f66206368617261637465727320746861742063616e2062652073656e7420696e20612073696e676c6520534d532074657874206d657373616765207472616e736d697373696f6e2028776869636820697320757375616c6c7920313630292e050003F202026031abc123send";

	 submitKannelMessage(inputXMLConnect);


}
}



SMS

Opinions expressed by DZone contributors are their own.

Related

  • Enhance Your Communication Strategy: Deliver Multimedia Messages With AWS Pinpoint
  • What Is Artificially Inflated Traffic?
  • Revolutionizing Customer Engagement: Unleashing the Magic of Communication APIs
  • Supercharge Your Communication With Twilio and Ballerina

Partner Resources


Comments

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: