Topic
6 replies Latest Post - ‏2011-04-11T17:15:12Z by Y436_Henry_Chin
Y436_Henry_Chin
Y436_Henry_Chin
6 Posts
ACCEPTED ANSWER

Pinned topic SipServletRequest.setContent() method causes exception

‏2011-04-08T20:37:56Z |
Hi everyone,
I have a question about setting SipServletRequest.setContent(sdp, contentType) method. I notice that when I use SipServletResponse.setContent() method just after creating it from request.createResponse() the contentType is NULL. So if I do not set the contentType before setting the content I get

InvocationTargetException CAUSE: java.lang.IllegalArgumentException: unsupported content type <garbage>

I got around this by setting the contentType before setting the content.

Now, I am not out of the woods yet. When I do the same thing with a new SipServletRequest I consistently get the same exception as before. Is there something special with SipServletRequest and setting content/contentType.

I am using WAS v7.0.0.15 with CEA v1.0.0.9. I checked the latest fix packs and see nothing related to contentType.
Regards,
Henry.
Updated on 2011-04-11T17:15:12Z at 2011-04-11T17:15:12Z by Y436_Henry_Chin
  • SystemAdmin
    SystemAdmin
    45 Posts
    ACCEPTED ANSWER

    Re: SipServletRequest.setContent() method causes exception

    ‏2011-04-11T12:52:34Z  in response to Y436_Henry_Chin
    Hi,
    Can you share the code snippet that causes to the exception in the response and request side?
    I'm not sure that I understand the exact API call and the content type that you are using.

    Asaf,
    • Y436_Henry_Chin
      Y436_Henry_Chin
      6 Posts
      ACCEPTED ANSWER

      Re: SipServletRequest.setContent() method causes exception

      ‏2011-04-11T15:00:59Z  in response to SystemAdmin
      Hi,
      If you call SipServletMessage.setContent(obj, type) method, where obj is any object that implements the toString() method. This will cause an exception to be thrown indicating that the contentType is invalid. However the logs shows the content type as "[93", strange for a content type even though I set the contentType before calling setContent.

      The work around for this problem is by creating a String object to pass as obj instead. I think WAS checks the instanceof the obj to determine if it is string. I would think that interface definition only requires an Object to be passed, in this case I would think WAS would call toString() method directly if it is not a String object.

      Regards,
      HC.
      • SystemAdmin
        SystemAdmin
        45 Posts
        ACCEPTED ANSWER

        Re: SipServletRequest.setContent() method causes exception

        ‏2011-04-11T15:26:57Z  in response to Y436_Henry_Chin
        What are you passing in the type attribute of the setContent method?

        from the API of JSR1.1 (SipServletMessage.setContent):
        "Furthermore, containers are required to handle String content when used with a text/* content type. When invoked with non-String objects and a text/* content type, containers may invoke toString() on the content Object in order to obtain the body's character data. It is also recommended that implementations know how to handle javax.mail.Multipart content when used together with "multipart" MIME types. "

        Websphere is calling toString on the object only if the type attribute is "text" according to the API, otherwise the content attribute should be String or IllegalStateException is thrown.
        • Y436_Henry_Chin
          Y436_Henry_Chin
          6 Posts
          ACCEPTED ANSWER

          Re: SipServletRequest.setContent() method causes exception

          ‏2011-04-11T15:50:27Z  in response to SystemAdmin
          Hi,
          I am passing javax.sdp.SessionDescription object which is from JAIN SIP SDP package. This package allows me to create SDP content. The contentType is "application/sdp", this is standard for SDP content type. It seems strange to set content type to "text/*" for SDP data. Clients receiving contentType "text/*" may react differently.
          Regards,
          HC.
          • SystemAdmin
            SystemAdmin
            45 Posts
            ACCEPTED ANSWER

            Re: SipServletRequest.setContent() method causes exception

            ‏2011-04-11T16:43:56Z  in response to Y436_Henry_Chin
            You should use the setContentType to add the content type headers with application/sdp.

            SIP container does not know how to serialize the SessionDescription Object, and if it is not "text" type the sip container is not allowed to just do toString on it, this is all according to JSR289

            You have 2 options:
            1. do toString yourself, Websphere SIP container will use the String as the message body and the application/sdp as the content-type
            2. use byte[] instead of SessionDescription, with application/sdp as the content-type, in this way the application is doing the serialization for the SIP container and according to the JSR SIP container must support it with any contentType.