You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by liucong <li...@gmail.com> on 2009/05/05 06:53:48 UTC

How to determine whether a soap message have an attachment

Hi all,

When I want to add MTOM support for SOAP/JMS, I should know whether a
soap message have an attachment. But I don't know the details how to
judge wheter the message have an attachment.
Is anyone give me any prompt about where the code is? Or some code example?

Thank you very much.

Best regards

Liu

Re: How to determine whether a soap message have an attachment

Posted by Willem Jiang <wi...@gmail.com>.
Yes, I confirmed that.
Please feel free to add your comments and patch on the JIRA CXF-1760.

We can add a check point in the JMSConduit.sendExchange() to show some
warning or throw the exception if the user forget to add the messageType
configuration.

Willem


liucong wrote:
> If the config <jms:client messageType="byte"/> doesn't appear in the
> WSDL of the service. The current implementation of JMS Transport will
> send MTOM message as TextMessage. So in current implementation, if one
> wants to use JMS MTOM-support, the config <jms:client
> messageType="byte"/> must be set, then the MTOM message will be sent as
> ByteMessage.
> 
> Willem Jiang wrote:
>> After digging the code, I found we could know if the Message has
>> attachments by looking the message in the JMSConduit.sendExchange()
>> method. We can tell if the message is MTOM enabled and has the
>> attachement message, then we just make sure the JMS Message type is
>> BytesMessage that should be OK.
>>
>> BTW, Freeman did some work to make the JMS transport support MTOM[1]
>>
>> [1] http://issues.apache.org/jira/browse/CXF-1760
>>
>> Willem
>>
>> Willem Jiang wrote:
>>   
>>> Hi,
>>>
>>> If we defer the creation of JMS Message until we know the Content-Type
>>> for the client, we still need to flight with the miss configuration of
>>> MTOM with TextMessage on the server side.
>>>
>>> Current solution , I discussed with Liu Cong is if the MTOM is enabled,
>>> CXF JMS transport will check the configuration of the JMS message type,
>>> and make sure the JMS message type is BytesMessage, if not, the JMS
>>> transport will throw an Exception for it.
>>>
>>> Any thought?
>>>
>>> Willem
>>>
>>> Daniel Kulp wrote:
>>>     
>>>> On Wed May 6 2009 9:15:54 am Willem Jiang wrote:
>>>>       
>>>>> Hi
>>>>>
>>>>> I think MTOM message should have the attachment info, we could check
>>>>> that for it. We have some trouble to send the MTOM message if we send
>>>>> the message in Text model, and Liu Cong is working on the patch.
>>>>>         
>>>> Hmm....    the message won't have the attachment info at "prepare" time.   
>>>> Whether to switch to mtom/mime or not is done later on, in the 
>>>> AttachmentOutInterceptor.    The actual creation of the JMS message might need 
>>>> to be deferred until the first call to write on the cached output stream or 
>>>> something.   At that point, the Content-Type should be set to the mime version 
>>>> and thus could be determined if it needs to be a binary message or not.
>>>>
>>>> Dan
>>>>
>>>>
>>>>
>>>>       
>>>>> Willem
>>>>>
>>>>> Daniel Kulp wrote:
>>>>>         
>>>>>> Doesn't it already support MTOM?
>>>>>>
>>>>>> Basically, it provides a OutputSteam to the dispatching and if the
>>>>>> runtime needs to handle attachments and such, it will write it as mime
>>>>>> stuff to the stream.
>>>>>>
>>>>>> Dan
>>>>>>
>>>>>> On Tue May 5 2009 12:53:48 am liucong wrote:
>>>>>>           
>>>>>>> Hi all,
>>>>>>>
>>>>>>> When I want to add MTOM support for SOAP/JMS, I should know whether a
>>>>>>> soap message have an attachment. But I don't know the details how to
>>>>>>> judge wheter the message have an attachment.
>>>>>>> Is anyone give me any prompt about where the code is? Or some code
>>>>>>> example?
>>>>>>>
>>>>>>> Thank you very much.
>>>>>>>
>>>>>>> Best regards
>>>>>>>
>>>>>>> Liu
>>>>>>>             
>>>     
>>
>>   
> 
> 


Re: How to determine whether a soap message have an attachment

Posted by liucong <li...@gmail.com>.
If the config <jms:client messageType="byte"/> doesn't appear in the
WSDL of the service. The current implementation of JMS Transport will
send MTOM message as TextMessage. So in current implementation, if one
wants to use JMS MTOM-support, the config <jms:client
messageType="byte"/> must be set, then the MTOM message will be sent as
ByteMessage.

Willem Jiang wrote:
> After digging the code, I found we could know if the Message has
> attachments by looking the message in the JMSConduit.sendExchange()
> method. We can tell if the message is MTOM enabled and has the
> attachement message, then we just make sure the JMS Message type is
> BytesMessage that should be OK.
>
> BTW, Freeman did some work to make the JMS transport support MTOM[1]
>
> [1] http://issues.apache.org/jira/browse/CXF-1760
>
> Willem
>
> Willem Jiang wrote:
>   
>> Hi,
>>
>> If we defer the creation of JMS Message until we know the Content-Type
>> for the client, we still need to flight with the miss configuration of
>> MTOM with TextMessage on the server side.
>>
>> Current solution , I discussed with Liu Cong is if the MTOM is enabled,
>> CXF JMS transport will check the configuration of the JMS message type,
>> and make sure the JMS message type is BytesMessage, if not, the JMS
>> transport will throw an Exception for it.
>>
>> Any thought?
>>
>> Willem
>>
>> Daniel Kulp wrote:
>>     
>>> On Wed May 6 2009 9:15:54 am Willem Jiang wrote:
>>>       
>>>> Hi
>>>>
>>>> I think MTOM message should have the attachment info, we could check
>>>> that for it. We have some trouble to send the MTOM message if we send
>>>> the message in Text model, and Liu Cong is working on the patch.
>>>>         
>>> Hmm....    the message won't have the attachment info at "prepare" time.   
>>> Whether to switch to mtom/mime or not is done later on, in the 
>>> AttachmentOutInterceptor.    The actual creation of the JMS message might need 
>>> to be deferred until the first call to write on the cached output stream or 
>>> something.   At that point, the Content-Type should be set to the mime version 
>>> and thus could be determined if it needs to be a binary message or not.
>>>
>>> Dan
>>>
>>>
>>>
>>>       
>>>> Willem
>>>>
>>>> Daniel Kulp wrote:
>>>>         
>>>>> Doesn't it already support MTOM?
>>>>>
>>>>> Basically, it provides a OutputSteam to the dispatching and if the
>>>>> runtime needs to handle attachments and such, it will write it as mime
>>>>> stuff to the stream.
>>>>>
>>>>> Dan
>>>>>
>>>>> On Tue May 5 2009 12:53:48 am liucong wrote:
>>>>>           
>>>>>> Hi all,
>>>>>>
>>>>>> When I want to add MTOM support for SOAP/JMS, I should know whether a
>>>>>> soap message have an attachment. But I don't know the details how to
>>>>>> judge wheter the message have an attachment.
>>>>>> Is anyone give me any prompt about where the code is? Or some code
>>>>>> example?
>>>>>>
>>>>>> Thank you very much.
>>>>>>
>>>>>> Best regards
>>>>>>
>>>>>> Liu
>>>>>>             
>>     
>
>
>   


Re: How to determine whether a soap message have an attachment

Posted by Willem Jiang <wi...@gmail.com>.
After digging the code, I found we could know if the Message has
attachments by looking the message in the JMSConduit.sendExchange()
method. We can tell if the message is MTOM enabled and has the
attachement message, then we just make sure the JMS Message type is
BytesMessage that should be OK.

BTW, Freeman did some work to make the JMS transport support MTOM[1]

[1] http://issues.apache.org/jira/browse/CXF-1760

Willem

Willem Jiang wrote:
> Hi,
> 
> If we defer the creation of JMS Message until we know the Content-Type
> for the client, we still need to flight with the miss configuration of
> MTOM with TextMessage on the server side.
> 
> Current solution , I discussed with Liu Cong is if the MTOM is enabled,
> CXF JMS transport will check the configuration of the JMS message type,
> and make sure the JMS message type is BytesMessage, if not, the JMS
> transport will throw an Exception for it.
> 
> Any thought?
> 
> Willem
> 
> Daniel Kulp wrote:
>> On Wed May 6 2009 9:15:54 am Willem Jiang wrote:
>>> Hi
>>>
>>> I think MTOM message should have the attachment info, we could check
>>> that for it. We have some trouble to send the MTOM message if we send
>>> the message in Text model, and Liu Cong is working on the patch.
>> Hmm....    the message won't have the attachment info at "prepare" time.   
>> Whether to switch to mtom/mime or not is done later on, in the 
>> AttachmentOutInterceptor.    The actual creation of the JMS message might need 
>> to be deferred until the first call to write on the cached output stream or 
>> something.   At that point, the Content-Type should be set to the mime version 
>> and thus could be determined if it needs to be a binary message or not.
>>
>> Dan
>>
>>
>>
>>> Willem
>>>
>>> Daniel Kulp wrote:
>>>> Doesn't it already support MTOM?
>>>>
>>>> Basically, it provides a OutputSteam to the dispatching and if the
>>>> runtime needs to handle attachments and such, it will write it as mime
>>>> stuff to the stream.
>>>>
>>>> Dan
>>>>
>>>> On Tue May 5 2009 12:53:48 am liucong wrote:
>>>>> Hi all,
>>>>>
>>>>> When I want to add MTOM support for SOAP/JMS, I should know whether a
>>>>> soap message have an attachment. But I don't know the details how to
>>>>> judge wheter the message have an attachment.
>>>>> Is anyone give me any prompt about where the code is? Or some code
>>>>> example?
>>>>>
>>>>> Thank you very much.
>>>>>
>>>>> Best regards
>>>>>
>>>>> Liu
> 
> 


Re: How to determine whether a soap message have an attachment

Posted by Willem Jiang <wi...@gmail.com>.
Hi,

If we defer the creation of JMS Message until we know the Content-Type
for the client, we still need to flight with the miss configuration of
MTOM with TextMessage on the server side.

Current solution , I discussed with Liu Cong is if the MTOM is enabled,
CXF JMS transport will check the configuration of the JMS message type,
and make sure the JMS message type is BytesMessage, if not, the JMS
transport will throw an Exception for it.

Any thought?

Willem

Daniel Kulp wrote:
> On Wed May 6 2009 9:15:54 am Willem Jiang wrote:
>> Hi
>>
>> I think MTOM message should have the attachment info, we could check
>> that for it. We have some trouble to send the MTOM message if we send
>> the message in Text model, and Liu Cong is working on the patch.
> 
> Hmm....    the message won't have the attachment info at "prepare" time.   
> Whether to switch to mtom/mime or not is done later on, in the 
> AttachmentOutInterceptor.    The actual creation of the JMS message might need 
> to be deferred until the first call to write on the cached output stream or 
> something.   At that point, the Content-Type should be set to the mime version 
> and thus could be determined if it needs to be a binary message or not.
> 
> Dan
> 
> 
> 
>> Willem
>>
>> Daniel Kulp wrote:
>>> Doesn't it already support MTOM?
>>>
>>> Basically, it provides a OutputSteam to the dispatching and if the
>>> runtime needs to handle attachments and such, it will write it as mime
>>> stuff to the stream.
>>>
>>> Dan
>>>
>>> On Tue May 5 2009 12:53:48 am liucong wrote:
>>>> Hi all,
>>>>
>>>> When I want to add MTOM support for SOAP/JMS, I should know whether a
>>>> soap message have an attachment. But I don't know the details how to
>>>> judge wheter the message have an attachment.
>>>> Is anyone give me any prompt about where the code is? Or some code
>>>> example?
>>>>
>>>> Thank you very much.
>>>>
>>>> Best regards
>>>>
>>>> Liu
> 


Re: How to determine whether a soap message have an attachment

Posted by Daniel Kulp <dk...@apache.org>.
On Wed May 6 2009 9:15:54 am Willem Jiang wrote:
> Hi
>
> I think MTOM message should have the attachment info, we could check
> that for it. We have some trouble to send the MTOM message if we send
> the message in Text model, and Liu Cong is working on the patch.

Hmm....    the message won't have the attachment info at "prepare" time.   
Whether to switch to mtom/mime or not is done later on, in the 
AttachmentOutInterceptor.    The actual creation of the JMS message might need 
to be deferred until the first call to write on the cached output stream or 
something.   At that point, the Content-Type should be set to the mime version 
and thus could be determined if it needs to be a binary message or not.

Dan



>
> Willem
>
> Daniel Kulp wrote:
> > Doesn't it already support MTOM?
> >
> > Basically, it provides a OutputSteam to the dispatching and if the
> > runtime needs to handle attachments and such, it will write it as mime
> > stuff to the stream.
> >
> > Dan
> >
> > On Tue May 5 2009 12:53:48 am liucong wrote:
> >> Hi all,
> >>
> >> When I want to add MTOM support for SOAP/JMS, I should know whether a
> >> soap message have an attachment. But I don't know the details how to
> >> judge wheter the message have an attachment.
> >> Is anyone give me any prompt about where the code is? Or some code
> >> example?
> >>
> >> Thank you very much.
> >>
> >> Best regards
> >>
> >> Liu

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog

Re: How to determine whether a soap message have an attachment

Posted by Willem Jiang <wi...@gmail.com>.
Hi

I think MTOM message should have the attachment info, we could check
that for it. We have some trouble to send the MTOM message if we send
the message in Text model, and Liu Cong is working on the patch.

Willem


Daniel Kulp wrote:
> Doesn't it already support MTOM?
> 
> Basically, it provides a OutputSteam to the dispatching and if the runtime 
> needs to handle attachments and such, it will write it as mime stuff to the 
> stream. 
> 
> Dan
> 
> 
> 
> On Tue May 5 2009 12:53:48 am liucong wrote:
>> Hi all,
>>
>> When I want to add MTOM support for SOAP/JMS, I should know whether a
>> soap message have an attachment. But I don't know the details how to
>> judge wheter the message have an attachment.
>> Is anyone give me any prompt about where the code is? Or some code example?
>>
>> Thank you very much.
>>
>> Best regards
>>
>> Liu
> 


Re: How to determine whether a soap message have an attachment

Posted by liucong <li...@gmail.com>.
Hi,
It already supports MTOM. But there may be a bug for the MTOM.
The current implementation send all the messages as TextMessage because
jmsConfig variable in JMSConduit is not initialized according to the
MessageType of SOAPMessage. So it is wrong when the message has an
attachment.

Sorry, I use the wrong word 'add MTOM support'. I just want to make the
'MTOM-support' work right.

Yes, I have followed some codes. I think it use a OutputStream to
generate the MTOM message. But before I send the message, I want to know
whether it is a MTOM message, because I should set ByteMessage or
TextMessage for JMS message depends on whether it is a MTOM message.
So far, I can't find a way to finish this.

Daniel Kulp 写道:
> Doesn't it already support MTOM?
>
> Basically, it provides a OutputSteam to the dispatching and if the runtime 
> needs to handle attachments and such, it will write it as mime stuff to the 
> stream. 
>
> Dan
>
>
>
> On Tue May 5 2009 12:53:48 am liucong wrote:
>   
>> Hi all,
>>
>> When I want to add MTOM support for SOAP/JMS, I should know whether a
>> soap message have an attachment. But I don't know the details how to
>> judge wheter the message have an attachment.
>> Is anyone give me any prompt about where the code is? Or some code example?
>>
>> Thank you very much.
>>
>> Best regards
>>
>> Liu
>>     
>
>   


Re: How to determine whether a soap message have an attachment

Posted by Daniel Kulp <dk...@apache.org>.
Doesn't it already support MTOM?

Basically, it provides a OutputSteam to the dispatching and if the runtime 
needs to handle attachments and such, it will write it as mime stuff to the 
stream. 

Dan



On Tue May 5 2009 12:53:48 am liucong wrote:
> Hi all,
>
> When I want to add MTOM support for SOAP/JMS, I should know whether a
> soap message have an attachment. But I don't know the details how to
> judge wheter the message have an attachment.
> Is anyone give me any prompt about where the code is? Or some code example?
>
> Thank you very much.
>
> Best regards
>
> Liu

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog