Example of the MMS mesg for sending MMS to MMSC

Example of the MMS mesg for sending MMS to MMSC SearchSearch
Author Message
Sharmila Ravula
Posted on Friday, January 31, 2003 - 11:15 pm:   

Hi
I would like to create an MMS mesg using a Java program and send it to the MMS gateway's Send MMS message html page to route it to the phone. Could you please tell me what MMS mesg form data is reqd in terms of subject info or file upload and give an example? This would give me a better idea on what to to incorporate in my HTTP POST connection to the MMS server. Thanks in advance

Sharmila
Bryce Norwood - NowSMS Support (Bryce)
Posted on Monday, February 03, 2003 - 03:26 pm:   

Sharmila,

It sounds like you've already created your MMS message file, and just want to know how to send it.

I'm further assuming that you're looking to post it to the Now SMS/MMS Gateway.

To submit it the same way that the "Send MMS Message" form does in the gateway's web menu intergface, you need to do an HTTP POST in the "multipart/form-data" MIME type.

Basically, when you POST, it would look something like this:

POST / HTTP/1.0
Accept: */*
Content-type: multipart/form-data; boundary="--boundary-border--"
Content-length: xxxxx (size of content part of post)
Authorization: username:password (base64 encoded)

----boundary-border--
Content-Disposition: form-data; name="PhoneNumber"

+448080148324
----boundary-border--
Content-Disposition: form-data; name="MMSFrom"

sender@domain (or +38484753009)
----boundary-border--
Content-Disposition: form-data; name="MMSSubject"

Message Subject
----boundary-border--
Content-Disposition: form-data; name="MMSText"

An optional text part of the message.
----boundary-border--
Content-Disposition: form-data; name="MMSFile"; filename="original-filename.ext"
Content-type: Mime/Type

File data goes here
----boundary-border----


The content-type for the overall message is "multipart/form-data". As with other multipart MIME encoding, you must include a boundary that separates the multiple parts of the message.

It is very important to set the Content-length: field to specify the length of the multipart content that follows (this is how the server knows your HTTP post is complete).

The Authorization header specifies the username and password used to login to the gateway. It is in the format "username:password" and is Base64 encoded.

Then, the content has a part for each form variable.

The "PhoneNumber" variable is required, it is the phone number of the message recipient.

The "MMSFrom" variable is optional. It is the "From:" address to be used in the MMS message. (If sending a pre-compiled MMS message, this is used for the notification only.)

The "MMSSubject" variable is optional. It is the "Subject" line used in the MMS message. (If sending a pre-compiled MMS message, this is used for the notification only.)

The "MMSText" variable is optional. It contains a text part of the message.

The "MMSFile" variable is optional, and can be repeated multiple times. It contains binary file content for an uploaded file. If you're sending a pre-compiled MMS file, you'd only include the "MMSFile" variable once. If you're sending a message for the gateway to compile, you could include each of the individual message parts as a separate instance of the "MMSFile" variable.

-bn
Sharmila Ravula
Posted on Thursday, February 13, 2003 - 11:59 pm:   

Bryce

I created a java program to send the information you specified to the server. BUt when I run the program I keep an HTTP 401 error, which I thikn is for Authorization problems. I have encoded the username and password to Base64 and this matched the value displayed in the SMS log file when I send an MMS message directly from the web site. I am uploading an smil file that is auto-generated.

This is what the SMSDebug.log shows:
15:41:52:562 [4] ThreadProcessConnection: Processing connection from 192.168.123.10...

15:41:52:562 [4] ThreadProcessConnection: Processing request /Send%20MMS%20Message.htm
15:41:52:562 [4] ParseMultipart: POST /Send%20MMS%20Message.htm HTTP/1.1
Content-type: multipart/form-data; boundary=---------------------------7d33992320290
Content-length: 2620
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
Authorization: Basic Ym9zY2g6Ym9zY2g=
User-Agent: Java1.3.1_01
Host: 192.168.123.10:8800
Connection: keep-alive

PhoneNumber=2834037&MMSSubject=Directions_to_Destination&MMSFile=directions.smil&
15:41:52:578 [4] Debug: 1 recipient entries
15:41:52:578 [4] Debug: 2834037
15:41:52:578 [4] ParsePostValue: MMSFile=directions.smil
15:41:52:578 [4] ParsePostValue: MMSFile=directions.smil
15:41:52:578 [4] ParsePostValue: MMSFile=directions.smil
15:41:55:796 [4] ParsePostValue: MMSFile=directions.smil
15:41:55:796 [4] Redirect: Location: http://192.168.123.10:8800/?PhoneNumber=2834037&MMSURL=w114.z208177157.sjc-ca.dsl.cnc.net:80/20030213/15/3E4AFDDBa.MMS&MMSSUBJECT=Directions_to_Destination
15:41:55:796 [4] ThreadProcessConnection: Processing connection from 192.168.123.10...

And in the java program I can see the following:
java.io.IOException: Server returned HTTP response code: 401 for URL: http://192
.168.123.10:8800/?PhoneNumber=2834037&MMSURL=w114.z208177157.sjc-ca.dsl.cnc.net:
80/20030213/15/3E4AFDDBa.MMS&MMSSUBJECT=Directions_to_Destination

Could you tell me wht could be going wrong, please?

Thanks in advance
Sharmila
Bryce Norwood - NowSMS Support (Bryce)
Posted on Friday, February 14, 2003 - 04:00 am:   

Sharmila,

I think you're almost there.

Are you currently able to use the "Send MMS Message" form in the web menu interface to send an MMS message? I suspect you'd get an error with that as well.

It looks like you've configured this as your MMSC host name:

w114.z208177157.sjc-ca.dsl.cnc.net

When you send an MMS message, the MMSC needs to store a copy of the message, and make that copy accessible so that the mobile phone can retrieve it with a URL request. (The MMS notification message that gets sent out to the phone has the message headers, plus this URL pointer to tell the phone where to download the content of the message from.)

When you use this particular interface to submit a message to the MMSC, it stores a copy of the message, and then tries to validate that the message could actually be retrieved from the MMSC.

But it looks like the local software is having problems connecting to the host name specified as the host name for the MMSC:

w114.z208177157.sjc-ca.dsl.cnc.net

Are you using a gateway to share a DSL connection?

If so, many times those gateways won't allow you to access internal resources using the external name.

You could try editing the HOSTS file in your \winnt\system32\drivers\etc directory and adding the following line:

127.0.0.1 w114.z208177157.sjc-ca.dsl.cnc.net


This will get you past the current error you are experiencing ... but then the next question is going to be whether or not the mobile phone that receives the message will be able to connect in to w114.z208177157.sjc-ca.dsl.cnc.net to retrieve the content of the MMS message.

-bn
Sharmila
Posted on Friday, February 14, 2003 - 07:46 pm:   

Bryce

Thanks for the reply. But I do not think the hostname is a problem. With the current configuration I can send messages from the web page and I am able to receive them on the phone.

I am having the HTTP 401 error only when I send a POST from my Java program. I can see the MMS file being created, but the server throws the HTTP 401 error.

Also I noticed another issue, I am sending an smil file with src tags in it. I did it both from the web menu interface and the program, but there seems to be a problem in sending just an smil file. From the web menu interface, when I send the smil file, it says the message is submitted, but when I look at the it on the cell phonhe, it is empty, it just shows a tag called page 1 and nothing else. When I send an smil file do I also need to upload all the image, text files?
Bryce Norwood - NowSMS Support (Bryce)
Posted on Saturday, February 15, 2003 - 12:10 am:   

Sharmila,

I'm not sure what is going on there. I'd normally expect to see a little more in the SMSDEBUG.LOG.

When you do a POST this way, we send a response back to the client that redirects it to another URL to send the notification.

I see the redirect response going out, but I don't see it coming back in. I've got a guess about what could be going on, which I will send to you via e-mail.

On the SMIL file, when you send a SMIL file, yes, you must upload all image and text files that go with it.

-bn
Sharmila
Posted on Saturday, February 15, 2003 - 01:42 am:   

Hi Bryce

I added the new file you sent me, but it does not seem to have made any difference. I still get the following errors. I run the Java program from the command line and see the following exception:

java.io.IOException: Server returned HTTP response code: 401 for URL: http://192
.168.123.10:8800/?PhoneNumber=2834037&MMSURL=w114.z208177157.sjc-ca.dsl.cnc.net/
20030214/17/3E4D9689a.MMS&MMSSUBJECT=Directions_to_Destination
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
nection.java:564)
at PostFileUpload.post(PostFileUpload.java:107)
at TestClass.main(TestClass.java:45)
-----------------------------------------------
And the SMSDebug.Log shows the following:

17:23:21:390 [4] ThreadProcessConnection: Processing connection from 192.168.123.10...

17:23:21:406 [4] ThreadProcessConnection: Processing request /Send
17:23:21:406 [4] ParseMultipart: POST /Send MMS Message.htm HTTP/1.1
Content-type: multipart/form-data; boundary=---------------------------7d33992320290
Content-length: 8893
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
Authorization: Basic Ym9zY2g6Ym9zY2g=
User-Agent: Java1.3.1_01
Host: 192.168.123.10:8800
Connection: keep-alive

PhoneNumber=2834037&MMSSubject=Directions_to_Destination&MMSFile=directions.MMS&
17:23:21:421 [4] Debug: 1 recipient entries
17:23:21:421 [4] Debug: 2834037
17:23:21:421 [4] ParsePostValue: MMSFile=directions.MMS
17:23:21:421 [4] ParsePostValue: MMSFile=directions.MMS
17:23:21:437 [4] Redirect: Location: http://192.168.123.10:8800/?PhoneNumber=2834037&MMSURL=w114.z208177157.sjc-ca.dsl.cnc.net/20030214/17/3E4D9689a.MMS&MMSSUBJECT=Directions_to_Destination
17:23:21:437 [4] ThreadProcessConnection: Processing connection from 192.168.123.10...

I looked up the HTTP 401 error and it says that authorization info is invalid. But as mentioned earlier, the encoded text matches what is being sent when I login to the web menu interface directly.

I would really appreciate it if you could give me any other suggestions.

Thanks
Sharmila
Bryce Norwood - NowSMS Support (Bryce)
Posted on Saturday, February 15, 2003 - 02:13 am:   

Sharmila,

I understand what is going on now. You're right ... 401 is an authorization error. I was thinking 404.

What is happening is that the server is responding to the initial request with a redirect response.

When the redirect is processed by the Java program, and the new request is issued by the Java program ... that request doesn't include an authorization header.

Let me go back and discuss this issue with some other folks.

Temporarily, you'd get around this error if you turned off "Require Authentication for Web interface". Obviously that's not a good long term solution, so I'll get back to you ... hopefully over the weekend. If you turn off authentication, be sure to define IP Address restrictions, and only allow your trusted IP addresses.

-bn
Sharmila
Posted on Tuesday, February 18, 2003 - 07:12 pm:   

HI Bryce

Thanks for the updated code. It works fine now.

Thanks again
Sharmila
Bryce Norwood - NowSMS Support (Bryce)
Posted on Wednesday, February 19, 2003 - 12:15 am:   

Great.

When we get around to posting a new release, I think others will like the change so that they don't have to deal with the HTTP Redirect. I hadn't thought about it, but that really does complicate HTTP authentication when you're working through a library.

-bn
Bryce Norwood - NowSMS Support
Board Administrator
Username: Bryce

Post Number: 984
Registered: 10-2002
Posted on Tuesday, October 28, 2003 - 04:35 pm:   

Follow-up: The redirect authorization issue described here was addressed by an updated release of the Now SMS/MMS Gateway.