×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Jun 2003
    Location
    North Finland
    Posts
    3

    Nokia Mobile Server Services Library 1.5: MMS with an attached text file (Unicode)

    I'm using Nokia Mobile Server Services Library 1.5. When creating a new MMS with an attached text file that is Unicode encoded, I get this message:

    com.nokia.mobile.services.api.DriverRemoteException: Message Validation Failed,error code='400'
    at com.nokia.mobile.services.driver.mms.eaif.MMSSender.send(MMSSender.java:126)
    at com.nokia.mobile.services.driver.mms.eaif.MMSEngineImpl.send(MMSEngineImpl.java:245)
    at xxx.MMSSender_NewAPI.send(MMSSender_NewAPI.java:400)
    at xxx.MainFrame.jButtonSend_actionPerformed(MainFrame.java:1423)
    at xxx.MainFrame_jButtonSend_actionAdapter.actionPerformed(MainFrame.java:2696)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)


    No problem with Windows- or ISO-encoded text files, however.. Is there another way to do it?

  2. #2
    Super Contributor
    Join Date
    Sep 2004
    Posts
    1,048
    Hello,

    When you are using the MMSDriverFactory.createMMSMessage(String[] urlArray) method to create a new MMSMessage the file-extensions are used to "guess" the content type. Mappings between file extensions and a content types can be created in the property file specified when getting the factory instance. If a there's no mapping defined in the property file the java.net.URLConnection.guessContentTypeFromName(String fname) method is used. For txt-files the content-type is set to text/plain, and the charset is always set to UTF8 by default (on a Windows platform).

    Probably what happens in your case is that you are sending a text file that is not UTF8 encoded. If the MMSC knows the content-type and it happens that the actual content is not correct it will return the error "Message Validation Failed". You can overcome this problem either by setting content and content-type explicitly, or you can define and use different extensions for different content and charset types. E.g. you can create an entry in the property file that looks like this:
    mmsc.Factory.file-extension.unicode=text/plain; charset=iso-10646-ucs-2

    Then an attached file called "my_text_file.txt" will get the content-type "text/plain; charset=utf-8", while "my_text_file.unicode" will get the content-type "text/plain; charset=iso-10646-ucs-2".

    Hope this solves your problem!

  3. #3
    Registered User
    Join Date
    Jun 2003
    Location
    North Finland
    Posts
    3
    Originally posted by mitts
    Hello,

    When you are using the MMSDriverFactory.createMMSMessage(String[] urlArray) method to create a new MMSMessage the file-extensions are used to "guess" the content type. Mappings between file extensions and a content types can be created in the property file specified when getting the factory instance. If a there's no mapping defined in the property file the java.net.URLConnection.guessContentTypeFromName(String fname) method is used. For txt-files the content-type is set to text/plain, and the charset is always set to UTF8 by default (on a Windows platform).

    Probably what happens in your case is that you are sending a text file that is not UTF8 encoded. If the MMSC knows the content-type and it happens that the actual content is not correct it will return the error "Message Validation Failed". You can overcome this problem either by setting content and content-type explicitly, or you can define and use different extensions for different content and charset types. E.g. you can create an entry in the property file that looks like this:
    mmsc.Factory.file-extension.unicode=text/plain; charset=iso-10646-ucs-2

    Then an attached file called "my_text_file.txt" will get the content-type "text/plain; charset=utf-8", while "my_text_file.unicode" will get the content-type "text/plain; charset=iso-10646-ucs-2".

    Hope this solves your problem!
    Yes indeed, this was the case!

    I wrote a little method "public String detectEncodingFromTextFile( String sFileName )" that detects the encoding of the first text file attached to the MMS.

    However, I suppose it is not possible to attach two text files with different encoding, like one with "windows-1252" and the other with "utf-8"? Not without changing the file extension, anyway..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×