you can try this,

MessageContext mc = new MessageContext();
FileDataSource dataSource =
           new FileDataSource("c:\\myImageAttachment.jpg");
       DataHandler dataHandler = new DataHandler(dataSource);

mc.addAttachment(dataHandler .getName(), dataHandler);

then add this message context to the client.

one more point, this is 'SwA' enabled attachment handling, so you have to
enabled SwA both in the server and client side.

Chinmoy



On Fri, Aug 28, 2009 at 8:11 AM, prabath <[email protected]> wrote:

> Please have a look at [1].
>
> Thanks & regards.
> -Prabath
>
> [1]:
> https://svn.apache.org/repos/asf/webservices/axis2/site/1_1/mtom-guide.html
>
>
> [email protected] wrote:
>
>>
>> Hello,
>>
>> I'm struggling to send a soap attachment with AXIS2.
>>
>> Most of the documentation I'm finding online is on receiving, rather than
>> sending attachments.  Here's the closest I've gathered to what the code
>> should sort of look like (which is surely wrong):
>>
>>
>>
>> stub._getServiceClient().getOptions().setProperty(Constants.Configuration.ENABLE_MTOM,
>>                                                Constants.VALUE_TRUE);
>>
>>       FileDataSource dataSource =
>>           new FileDataSource("c:\\myImageAttachment.jpg");
>>       DataHandler dataHandler = new DataHandler(dataSource);
>>
>> MessageContext.getCurrentMessageContext().addAttachment(dataHandler);
>>
>>
>>      stub.CreateIncident();
>>
>>
>> But that code does not work since getCurrentMessageContext returns null.
>>
>> Outside of attachments, the rest of the functionality works fine.
>>
>> It looks, to me, like the old version of Axis had an addAttachment method
>> on the stub API, but I don't see anything comparable in 2.
>>
>>
>> Any help would be appreciated.  Thanks.
>>
>> Sean
>>
>> This transmission is intended solely for the person or organization to
>> whom it is addressed and it may contain privileged and cofidential
>> information. If you are not the intended recipient you should not copy,
>> distribute or take any action in reliance on it. If you believe you received
>> this transmission in error please notify the sender.
>> 222 Merchandise Mart Plaza, Suite 250, Chicago, IL 60654, USA
>>
>>
>

Reply via email to