Results 1 to 8 of 8
Thread: Attach XML content in UDP socket
- 06-21-2011, 05:18 PM #1
Member
- Join Date
- Jun 2011
- Posts
- 4
- Rep Power
- 0
Attach XML content in UDP socket
Hai everybody,
I write a method to send a SIP message to a server by using UDP Socket. The problem arrives when I have to attached an xml file as the Content, the server dont receive the xml file and detect the Content-Length = 0. Thank you for giving me a hint on how to do this in UDP socket. Here is my method:
public static void sendNotify(){
final String notifyRequest = "NOTIFY sip:irsa@192.168.1.100:5064 SIP/2.0\r\n"+
"Via: SIP/2.0/UDP 192.168.1.101:5060;branch=z9hG4bK-393234-a9a4694bf5565e11365831f58ba0b522\r\n"+
"CSeq: 2 NOTIFY\r\n"+
"Call-ID: 0ha0isnda977644900765@10.0.0.1\r\n"+
"From: <sip:alice@open-ims.test>;tag=37d2721c\r\n"+
"To: <sip:irsa@open-ims.test>;tag=1026\r\n"+
"Call-ID: 0a11aced29850e7ccea884a679f0d888@192.168.1.100\r\n "+
"Contact: <sip:192.168.1.101:5060;transport=udp>\r\n"+
"Route: <sip:mo@scscf.open-ims.test:6060;lr>,<sip:mo@pcscf.open-ims.test:4060;lr>\r\n"+
"Event: presence\r\n" +
"Max-Forwards: 70\r\n" +
"Subscription-State: active;expires=3583\r\n" +
"Content-Type: application/pidf+xml\r\n" +
"P-Charging-Vector: icid-value=z9hG4bK-393234-6e5fcdf8a6da1a0c3f2923a42f6608c51308226155111;orig-ioi=mobicents.org\r\n" +
"Content-Length: 459\r\n"+
"<?xml version=\"1.0\" encoding=\"UTF-8\"?><presence xmlns=\"urn:ietf:params:xml:ns:pidf\" xmlns:dm=\"urn:ietf:params:xml:ns:pidf:data-model\" xmlns:op=\"urn:oma:xml:prs:pidf:oma-pres\" xmlns:opd=\"urn:oma:xml:pde:pidf:ext\" xmlns:rpidf=\"urn:ietf:params:xml:ns:pidf:rpid\" entity=\"sip:alice@open-ims.test\"><tuple id=\"com1\"><status><basic>open</basic></status></tuple><dm:person id=\"per123\"><rpidf:activities id=\"act1\"><rpidf:busy/></rpidf:activities></dm:person></presence> ";
byte[] notifyRequestBytes = notifyRequest.getBytes();
try {
localhost = InetAddress.getByName("10.193.193.46");
DatagramSocket socket = new DatagramSocket(33276, localhost);
socket.send(new DatagramPacket(notifyRequestBytes,notifyRequestByt es.length,localhost, 5060));
} catch (SocketException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Thank you!
- 06-21-2011, 05:51 PM #2
What code on the server is receiving the Datagram?
Where does "Content-Length" come from with Datagrams?detect the Content-Length = 0
- 06-21-2011, 06:09 PM #3
Member
- Join Date
- Jun 2011
- Posts
- 4
- Rep Power
- 0
I use application server Mobicents (which will receive my Sip message), So, I dont know exactly which code

I thought Content-Length comes from the length of the xml character/data that I put below the header?
- 06-21-2011, 06:15 PM #4
The string: Content-Length looks like a field in a HTTP request header.
If you are using Datagrams there wouldn't be a HTTP request header.
What protocols does your server use at the port you are using? Is it expecting a HTTP request?
Or does it receive a Datagram?
- 06-21-2011, 06:21 PM #5
Member
- Join Date
- Jun 2011
- Posts
- 4
- Rep Power
- 0
in sip protocol I saw that they use also content-length if I attache an xml. My server listens to UDP in port 5060. It is expecting SIP messages, actually.
Could you give me some hint?
Thanks!
- 06-21-2011, 06:24 PM #6
Sorry, I have no idea what a SIP message is or how a server processes it.
Google it and see if you are formatting the data correctly.Last edited by Norm; 06-21-2011 at 06:29 PM.
- 06-21-2011, 08:42 PM #7
Another idea: In HTTP there is a blank line between the header and the data. Does SIP have this? You could need:
Java Code:"Content-Length: 459\r\n\r\n" +
- 06-22-2011, 10:18 AM #8
Member
- Join Date
- Jun 2011
- Posts
- 4
- Rep Power
- 0
Similar Threads
-
mail content are not encoded as per content-transfer- encoding
By Luna Lovegood in forum New To JavaReplies: 1Last Post: 04-19-2011, 08:52 AM -
How to attach a listener to a folder
By bayan in forum New To JavaReplies: 1Last Post: 10-21-2010, 11:03 AM -
Attach Photos in SWT to database
By ashin in forum SWT / JFaceReplies: 0Last Post: 08-09-2010, 06:48 AM -
How to attach two BufferedImage to obtain 1 buffered image
By LankanSniper in forum Java 2DReplies: 4Last Post: 03-23-2010, 03:46 PM -
how can i attach a worg/image file
By sniffer139 in forum AWT / SwingReplies: 4Last Post: 03-12-2010, 06:49 AM


LinkBack URL
About LinkBacks
Reply With Quote
.gif)

Bookmarks