You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by StrongSteve <st...@starkeweb.org> on 2008/08/12 07:51:21 UTC

Axis2 - Handler to log all messages without attachments

Hi Everybody!

I am currently developing an Axis2 Handler that logs all SOAP Messages
targeted at my server into separate files.
The problem is, that many of these SOAP Messages contain files (binary
MTOM), which I do not want to log of course, as they just blow up the file
size. (Instead of the binary attachment transmission I want to add a simple
String like <ATTACHMENT REMOVED> or something like this.

I already have everything working, except the attachment handling. Here is
my code till now. (I have nothing with files or so on, I test it with plain
System.out.printlns)

public class LoggingHandler extends AbstractHandler {
 
	public InvocationResponse invoke(MessageContext msgCtx) throws AxisFault {
				
		SOAPEnvelope env = msgCtx.getEnvelope();
		
                System.out.println(env.toString());
               
		return InvocationResponse.CONTINUE;		
		
	}
 
}



So can anyone please help me with extracting the attachments?
I would be very glad! ;)

(Removing the Attachments with msgCtx.removeAttachment(AttachmentID), does
not work!!!)

Thanks in Advance for both your time and your knowledge!

Greeting
Stefan
-- 
View this message in context: http://www.nabble.com/Axis2---Handler-to-log-all-messages-without-attachments-tp18938449p18938449.html
Sent from the Axis - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Axis2 - Handler to log all messages without attachments

Posted by Thilina Gunarathne <cs...@gmail.com>.
You cannot remove MTOM attachments like that... They are more bound to the
XML object model..

Following works only for the SwA and only for the attachments you added...
Not to the one's that came in the request..

thanks,
Thilina

On Tue, Aug 12, 2008 at 7:23 AM, StrongSteve <st...@starkeweb.org> wrote:

>
> Like this:
>
>
>                 Attachments attachments = arg0.getAttachmentMap();
>                 String[] attachmentIds = attachments.getAllContentIDs();
>
>                 for (int i = 0; i < attachmentIds.length; i++) {
>                         arg0.removeAttachment(attachmentIds[i]);
>                 }
>
>                 SOAPEnvelope env = arg0.getEnvelope();
>                  System.out.println(env.toString());
>
>
>
>
> Samisa Abeysinghe-2 wrote:
> >
> > StrongSteve wrote:
> >> Hi!
> >>
> >> Thanks for your quick reply.
> >> I already know how to get to the attachments, but what I want to do, is
> >> log
> >> everything EXCEPT the attachments! ;)
> >>
> >> Removing them from the message, does not work. I do not know why... :(
> >>
> >
> > How did you remove them?
> >
> > Samisa...
> >
> >> And hints for me?
> >>
> >> Thanks in Advance!
> >>
> >> Greetings
> >> Stefan
> >>
> >>
> >> Thilina Gunarathne wrote:
> >>
> >>> Make sure you try the second method first :)..
> >>>
> >>> On Tue, Aug 12, 2008 at 12:01 AM, Thilina Gunarathne
> >>> <cs...@gmail.com>wrote:
> >>>
> >>>
> >>>> You can try traversing the whole envelope looking for <xop:include>
> >>>> elements and then detach those elements from the tree.. But doing this
> >>>> will
> >>>> cause the attachment information in the SOAP envelope to be lost and
> ur
> >>>> services may not function properly.
> >>>>
> >>>> One other thing you can try is to access the SOAP part data handler
> and
> >>>> log
> >>>> it's contents. You can do that by getting the soap part part content
> id
> >>>> using the Attachments.getSOAPPartContentID() and then using
> >>>> Attachments.getDataHandler(SOAPPartContentID) to get access to the
> SOAP
> >>>> part
> >>>> DataHandler. Then just write the contents of the DataHandler to the
> >>>> output
> >>>> stream.
> >>>>
> >>>> You can get access to the Attachments using msgCntx.getAttachmentMap()
> >>>> method.
> >>>>
> >>>> thanks,
> >>>> Thilina
> >>>>
> >>>>
> >>>> On Mon, Aug 11, 2008 at 10:51 PM, StrongSteve
> >>>> <st...@starkeweb.org>wrote:
> >>>>
> >>>>
> >>>>> Hi Everybody!
> >>>>>
> >>>>> I am currently developing an Axis2 Handler that logs all SOAP
> Messages
> >>>>> targeted at my server into separate files.
> >>>>> The problem is, that many of these SOAP Messages contain files
> (binary
> >>>>> MTOM), which I do not want to log of course, as they just blow up the
> >>>>> file
> >>>>> size. (Instead of the binary attachment transmission I want to add a
> >>>>> simple
> >>>>> String like <ATTACHMENT REMOVED> or something like this.
> >>>>>
> >>>>> I already have everything working, except the attachment handling.
> >>>>> Here
> >>>>> is
> >>>>> my code till now. (I have nothing with files or so on, I test it with
> >>>>> plain
> >>>>> System.out.printlns)
> >>>>>
> >>>>> public class LoggingHandler extends AbstractHandler {
> >>>>>
> >>>>>        public InvocationResponse invoke(MessageContext msgCtx) throws
> >>>>> AxisFault {
> >>>>>
> >>>>>                SOAPEnvelope env = msgCtx.getEnvelope();
> >>>>>
> >>>>>                System.out.println(env.toString());
> >>>>>
> >>>>>                return InvocationResponse.CONTINUE;
> >>>>>
> >>>>>        }
> >>>>>
> >>>>> }
> >>>>>
> >>>>>
> >>>>>
> >>>>> So can anyone please help me with extracting the attachments?
> >>>>> I would be very glad! ;)
> >>>>>
> >>>>> (Removing the Attachments with msgCtx.removeAttachment(AttachmentID),
> >>>>> does
> >>>>> not work!!!)
> >>>>>
> >>>>> Thanks in Advance for both your time and your knowledge!
> >>>>>
> >>>>> Greeting
> >>>>> Stefan
> >>>>> --
> >>>>> View this message in context:
> >>>>>
> http://www.nabble.com/Axis2---Handler-to-log-all-messages-without-attachments-tp18938449p18938449.html
> >>>>> Sent from the Axis - User mailing list archive at Nabble.com.
> >>>>>
> >>>>>
> >>>>> ---------------------------------------------------------------------
> >>>>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> >>>>> For additional commands, e-mail: axis-user-help@ws.apache.org
> >>>>>
> >>>>>
> >>>>>
> >>>> --
> >>>> Thilina Gunarathne - http://thilinag.blogspot.com
> >>>>
> >>>>
> >>>
> >>> --
> >>> Thilina Gunarathne - http://thilinag.blogspot.com
> >>>
> >>>
> >>>
> >>
> >>
> >
> >
> > --
> > Samisa Abeysinghe
> >
> > http://people.apache.org/~samisa/ <http://people.apache.org/%7Esamisa/>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> > For additional commands, e-mail: axis-user-help@ws.apache.org
> >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Axis2---Handler-to-log-all-messages-without-attachments-tp18938449p18945302.html
> Sent from the Axis - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>


-- 
Thilina Gunarathne - http://thilinag.blogspot.com

Re: Axis2 - Handler to log all messages without attachments

Posted by StrongSteve <st...@starkeweb.org>.
Like this:


		 Attachments attachments = arg0.getAttachmentMap();
		 String[] attachmentIds = attachments.getAllContentIDs();
		 
		 for (int i = 0; i < attachmentIds.length; i++) {
			 arg0.removeAttachment(attachmentIds[i]);
		 }
		
		 SOAPEnvelope env = arg0.getEnvelope();
		 System.out.println(env.toString());




Samisa Abeysinghe-2 wrote:
> 
> StrongSteve wrote:
>> Hi!
>>
>> Thanks for your quick reply.
>> I already know how to get to the attachments, but what I want to do, is
>> log
>> everything EXCEPT the attachments! ;)
>>
>> Removing them from the message, does not work. I do not know why... :(
>>   
> 
> How did you remove them?
> 
> Samisa...
> 
>> And hints for me?
>>
>> Thanks in Advance!
>>
>> Greetings
>> Stefan
>>
>>
>> Thilina Gunarathne wrote:
>>   
>>> Make sure you try the second method first :)..
>>>
>>> On Tue, Aug 12, 2008 at 12:01 AM, Thilina Gunarathne
>>> <cs...@gmail.com>wrote:
>>>
>>>     
>>>> You can try traversing the whole envelope looking for <xop:include>
>>>> elements and then detach those elements from the tree.. But doing this
>>>> will
>>>> cause the attachment information in the SOAP envelope to be lost and ur
>>>> services may not function properly.
>>>>
>>>> One other thing you can try is to access the SOAP part data handler and
>>>> log
>>>> it's contents. You can do that by getting the soap part part content id
>>>> using the Attachments.getSOAPPartContentID() and then using
>>>> Attachments.getDataHandler(SOAPPartContentID) to get access to the SOAP
>>>> part
>>>> DataHandler. Then just write the contents of the DataHandler to the
>>>> output
>>>> stream.
>>>>
>>>> You can get access to the Attachments using msgCntx.getAttachmentMap()
>>>> method.
>>>>
>>>> thanks,
>>>> Thilina
>>>>
>>>>
>>>> On Mon, Aug 11, 2008 at 10:51 PM, StrongSteve
>>>> <st...@starkeweb.org>wrote:
>>>>
>>>>       
>>>>> Hi Everybody!
>>>>>
>>>>> I am currently developing an Axis2 Handler that logs all SOAP Messages
>>>>> targeted at my server into separate files.
>>>>> The problem is, that many of these SOAP Messages contain files (binary
>>>>> MTOM), which I do not want to log of course, as they just blow up the
>>>>> file
>>>>> size. (Instead of the binary attachment transmission I want to add a
>>>>> simple
>>>>> String like <ATTACHMENT REMOVED> or something like this.
>>>>>
>>>>> I already have everything working, except the attachment handling.
>>>>> Here
>>>>> is
>>>>> my code till now. (I have nothing with files or so on, I test it with
>>>>> plain
>>>>> System.out.printlns)
>>>>>
>>>>> public class LoggingHandler extends AbstractHandler {
>>>>>
>>>>>        public InvocationResponse invoke(MessageContext msgCtx) throws
>>>>> AxisFault {
>>>>>
>>>>>                SOAPEnvelope env = msgCtx.getEnvelope();
>>>>>
>>>>>                System.out.println(env.toString());
>>>>>
>>>>>                return InvocationResponse.CONTINUE;
>>>>>
>>>>>        }
>>>>>
>>>>> }
>>>>>
>>>>>
>>>>>
>>>>> So can anyone please help me with extracting the attachments?
>>>>> I would be very glad! ;)
>>>>>
>>>>> (Removing the Attachments with msgCtx.removeAttachment(AttachmentID),
>>>>> does
>>>>> not work!!!)
>>>>>
>>>>> Thanks in Advance for both your time and your knowledge!
>>>>>
>>>>> Greeting
>>>>> Stefan
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/Axis2---Handler-to-log-all-messages-without-attachments-tp18938449p18938449.html
>>>>> Sent from the Axis - User mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>>>>> For additional commands, e-mail: axis-user-help@ws.apache.org
>>>>>
>>>>>
>>>>>         
>>>> --
>>>> Thilina Gunarathne - http://thilinag.blogspot.com
>>>>
>>>>       
>>>
>>> -- 
>>> Thilina Gunarathne - http://thilinag.blogspot.com
>>>
>>>
>>>     
>>
>>   
> 
> 
> -- 
> Samisa Abeysinghe
> 
> http://people.apache.org/~samisa/
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Axis2---Handler-to-log-all-messages-without-attachments-tp18938449p18945302.html
Sent from the Axis - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Axis2 - Handler to log all messages without attachments

Posted by Samisa Abeysinghe <sa...@gmail.com>.
StrongSteve wrote:
> Hi!
>
> Thanks for your quick reply.
> I already know how to get to the attachments, but what I want to do, is log
> everything EXCEPT the attachments! ;)
>
> Removing them from the message, does not work. I do not know why... :(
>   

How did you remove them?

Samisa...

> And hints for me?
>
> Thanks in Advance!
>
> Greetings
> Stefan
>
>
> Thilina Gunarathne wrote:
>   
>> Make sure you try the second method first :)..
>>
>> On Tue, Aug 12, 2008 at 12:01 AM, Thilina Gunarathne
>> <cs...@gmail.com>wrote:
>>
>>     
>>> You can try traversing the whole envelope looking for <xop:include>
>>> elements and then detach those elements from the tree.. But doing this
>>> will
>>> cause the attachment information in the SOAP envelope to be lost and ur
>>> services may not function properly.
>>>
>>> One other thing you can try is to access the SOAP part data handler and
>>> log
>>> it's contents. You can do that by getting the soap part part content id
>>> using the Attachments.getSOAPPartContentID() and then using
>>> Attachments.getDataHandler(SOAPPartContentID) to get access to the SOAP
>>> part
>>> DataHandler. Then just write the contents of the DataHandler to the
>>> output
>>> stream.
>>>
>>> You can get access to the Attachments using msgCntx.getAttachmentMap()
>>> method.
>>>
>>> thanks,
>>> Thilina
>>>
>>>
>>> On Mon, Aug 11, 2008 at 10:51 PM, StrongSteve
>>> <st...@starkeweb.org>wrote:
>>>
>>>       
>>>> Hi Everybody!
>>>>
>>>> I am currently developing an Axis2 Handler that logs all SOAP Messages
>>>> targeted at my server into separate files.
>>>> The problem is, that many of these SOAP Messages contain files (binary
>>>> MTOM), which I do not want to log of course, as they just blow up the
>>>> file
>>>> size. (Instead of the binary attachment transmission I want to add a
>>>> simple
>>>> String like <ATTACHMENT REMOVED> or something like this.
>>>>
>>>> I already have everything working, except the attachment handling. Here
>>>> is
>>>> my code till now. (I have nothing with files or so on, I test it with
>>>> plain
>>>> System.out.printlns)
>>>>
>>>> public class LoggingHandler extends AbstractHandler {
>>>>
>>>>        public InvocationResponse invoke(MessageContext msgCtx) throws
>>>> AxisFault {
>>>>
>>>>                SOAPEnvelope env = msgCtx.getEnvelope();
>>>>
>>>>                System.out.println(env.toString());
>>>>
>>>>                return InvocationResponse.CONTINUE;
>>>>
>>>>        }
>>>>
>>>> }
>>>>
>>>>
>>>>
>>>> So can anyone please help me with extracting the attachments?
>>>> I would be very glad! ;)
>>>>
>>>> (Removing the Attachments with msgCtx.removeAttachment(AttachmentID),
>>>> does
>>>> not work!!!)
>>>>
>>>> Thanks in Advance for both your time and your knowledge!
>>>>
>>>> Greeting
>>>> Stefan
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/Axis2---Handler-to-log-all-messages-without-attachments-tp18938449p18938449.html
>>>> Sent from the Axis - User mailing list archive at Nabble.com.
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>>>> For additional commands, e-mail: axis-user-help@ws.apache.org
>>>>
>>>>
>>>>         
>>> --
>>> Thilina Gunarathne - http://thilinag.blogspot.com
>>>
>>>       
>>
>> -- 
>> Thilina Gunarathne - http://thilinag.blogspot.com
>>
>>
>>     
>
>   


-- 
Samisa Abeysinghe

http://people.apache.org/~samisa/


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Axis2 - Handler to log all messages without attachments

Posted by Thilina Gunarathne <cs...@gmail.com>.
hmmm.. You need to read more carefully...

"One other thing you can try is to access the SOAP part data handler and log
it's contents. You can do that by getting the soap part part content id
using the Attachments.getSOAPPartContentID() and then using
Attachments.getDataHandler(SOAPPartContentID) to get access to the SOAP part
DataHandler. Then just write the contents of the DataHandler to the output
stream."

Writing SOAP part contents will give you wat u need...

~Thilina


On Tue, Aug 12, 2008 at 3:23 AM, StrongSteve <st...@starkeweb.org> wrote:

>
> Hi!
>
> Thanks for your quick reply.
> I already know how to get to the attachments, but what I want to do, is log
> everything EXCEPT the attachments! ;)
>
> Removing them from the message, does not work. I do not know why... :(
>
> And hints for me?
>
> Thanks in Advance!
>
> Greetings
> Stefan
>
>
> Thilina Gunarathne wrote:
> >
> > Make sure you try the second method first :)..
> >
> > On Tue, Aug 12, 2008 at 12:01 AM, Thilina Gunarathne
> > <cs...@gmail.com>wrote:
> >
> >> You can try traversing the whole envelope looking for <xop:include>
> >> elements and then detach those elements from the tree.. But doing this
> >> will
> >> cause the attachment information in the SOAP envelope to be lost and ur
> >> services may not function properly.
> >>
> >> One other thing you can try is to access the SOAP part data handler and
> >> log
> >> it's contents. You can do that by getting the soap part part content id
> >> using the Attachments.getSOAPPartContentID() and then using
> >> Attachments.getDataHandler(SOAPPartContentID) to get access to the SOAP
> >> part
> >> DataHandler. Then just write the contents of the DataHandler to the
> >> output
> >> stream.
> >>
> >> You can get access to the Attachments using msgCntx.getAttachmentMap()
> >> method.
> >>
> >> thanks,
> >> Thilina
> >>
> >>
> >> On Mon, Aug 11, 2008 at 10:51 PM, StrongSteve
> >> <st...@starkeweb.org>wrote:
> >>
> >>>
> >>> Hi Everybody!
> >>>
> >>> I am currently developing an Axis2 Handler that logs all SOAP Messages
> >>> targeted at my server into separate files.
> >>> The problem is, that many of these SOAP Messages contain files (binary
> >>> MTOM), which I do not want to log of course, as they just blow up the
> >>> file
> >>> size. (Instead of the binary attachment transmission I want to add a
> >>> simple
> >>> String like <ATTACHMENT REMOVED> or something like this.
> >>>
> >>> I already have everything working, except the attachment handling. Here
> >>> is
> >>> my code till now. (I have nothing with files or so on, I test it with
> >>> plain
> >>> System.out.printlns)
> >>>
> >>> public class LoggingHandler extends AbstractHandler {
> >>>
> >>>        public InvocationResponse invoke(MessageContext msgCtx) throws
> >>> AxisFault {
> >>>
> >>>                SOAPEnvelope env = msgCtx.getEnvelope();
> >>>
> >>>                System.out.println(env.toString());
> >>>
> >>>                return InvocationResponse.CONTINUE;
> >>>
> >>>        }
> >>>
> >>> }
> >>>
> >>>
> >>>
> >>> So can anyone please help me with extracting the attachments?
> >>> I would be very glad! ;)
> >>>
> >>> (Removing the Attachments with msgCtx.removeAttachment(AttachmentID),
> >>> does
> >>> not work!!!)
> >>>
> >>> Thanks in Advance for both your time and your knowledge!
> >>>
> >>> Greeting
> >>> Stefan
> >>> --
> >>> View this message in context:
> >>>
> http://www.nabble.com/Axis2---Handler-to-log-all-messages-without-attachments-tp18938449p18938449.html
> >>> Sent from the Axis - User mailing list archive at Nabble.com.
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> >>> For additional commands, e-mail: axis-user-help@ws.apache.org
> >>>
> >>>
> >>
> >>
> >> --
> >> Thilina Gunarathne - http://thilinag.blogspot.com
> >>
> >
> >
> >
> > --
> > Thilina Gunarathne - http://thilinag.blogspot.com
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/Axis2---Handler-to-log-all-messages-without-attachments-tp18938449p18941523.html
> Sent from the Axis - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>


-- 
Thilina Gunarathne - http://thilinag.blogspot.com

Re: Axis2 - Handler to log all messages without attachments

Posted by StrongSteve <st...@starkeweb.org>.
Hi!

Thanks for your quick reply.
I already know how to get to the attachments, but what I want to do, is log
everything EXCEPT the attachments! ;)

Removing them from the message, does not work. I do not know why... :(

And hints for me?

Thanks in Advance!

Greetings
Stefan


Thilina Gunarathne wrote:
> 
> Make sure you try the second method first :)..
> 
> On Tue, Aug 12, 2008 at 12:01 AM, Thilina Gunarathne
> <cs...@gmail.com>wrote:
> 
>> You can try traversing the whole envelope looking for <xop:include>
>> elements and then detach those elements from the tree.. But doing this
>> will
>> cause the attachment information in the SOAP envelope to be lost and ur
>> services may not function properly.
>>
>> One other thing you can try is to access the SOAP part data handler and
>> log
>> it's contents. You can do that by getting the soap part part content id
>> using the Attachments.getSOAPPartContentID() and then using
>> Attachments.getDataHandler(SOAPPartContentID) to get access to the SOAP
>> part
>> DataHandler. Then just write the contents of the DataHandler to the
>> output
>> stream.
>>
>> You can get access to the Attachments using msgCntx.getAttachmentMap()
>> method.
>>
>> thanks,
>> Thilina
>>
>>
>> On Mon, Aug 11, 2008 at 10:51 PM, StrongSteve
>> <st...@starkeweb.org>wrote:
>>
>>>
>>> Hi Everybody!
>>>
>>> I am currently developing an Axis2 Handler that logs all SOAP Messages
>>> targeted at my server into separate files.
>>> The problem is, that many of these SOAP Messages contain files (binary
>>> MTOM), which I do not want to log of course, as they just blow up the
>>> file
>>> size. (Instead of the binary attachment transmission I want to add a
>>> simple
>>> String like <ATTACHMENT REMOVED> or something like this.
>>>
>>> I already have everything working, except the attachment handling. Here
>>> is
>>> my code till now. (I have nothing with files or so on, I test it with
>>> plain
>>> System.out.printlns)
>>>
>>> public class LoggingHandler extends AbstractHandler {
>>>
>>>        public InvocationResponse invoke(MessageContext msgCtx) throws
>>> AxisFault {
>>>
>>>                SOAPEnvelope env = msgCtx.getEnvelope();
>>>
>>>                System.out.println(env.toString());
>>>
>>>                return InvocationResponse.CONTINUE;
>>>
>>>        }
>>>
>>> }
>>>
>>>
>>>
>>> So can anyone please help me with extracting the attachments?
>>> I would be very glad! ;)
>>>
>>> (Removing the Attachments with msgCtx.removeAttachment(AttachmentID),
>>> does
>>> not work!!!)
>>>
>>> Thanks in Advance for both your time and your knowledge!
>>>
>>> Greeting
>>> Stefan
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Axis2---Handler-to-log-all-messages-without-attachments-tp18938449p18938449.html
>>> Sent from the Axis - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>>> For additional commands, e-mail: axis-user-help@ws.apache.org
>>>
>>>
>>
>>
>> --
>> Thilina Gunarathne - http://thilinag.blogspot.com
>>
> 
> 
> 
> -- 
> Thilina Gunarathne - http://thilinag.blogspot.com
> 
> 

-- 
View this message in context: http://www.nabble.com/Axis2---Handler-to-log-all-messages-without-attachments-tp18938449p18941523.html
Sent from the Axis - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Axis2 - Handler to log all messages without attachments

Posted by Thilina Gunarathne <cs...@gmail.com>.
Make sure you try the second method first :)..

On Tue, Aug 12, 2008 at 12:01 AM, Thilina Gunarathne <cs...@gmail.com>wrote:

> You can try traversing the whole envelope looking for <xop:include>
> elements and then detach those elements from the tree.. But doing this will
> cause the attachment information in the SOAP envelope to be lost and ur
> services may not function properly.
>
> One other thing you can try is to access the SOAP part data handler and log
> it's contents. You can do that by getting the soap part part content id
> using the Attachments.getSOAPPartContentID() and then using
> Attachments.getDataHandler(SOAPPartContentID) to get access to the SOAP part
> DataHandler. Then just write the contents of the DataHandler to the output
> stream.
>
> You can get access to the Attachments using msgCntx.getAttachmentMap()
> method.
>
> thanks,
> Thilina
>
>
> On Mon, Aug 11, 2008 at 10:51 PM, StrongSteve <st...@starkeweb.org>wrote:
>
>>
>> Hi Everybody!
>>
>> I am currently developing an Axis2 Handler that logs all SOAP Messages
>> targeted at my server into separate files.
>> The problem is, that many of these SOAP Messages contain files (binary
>> MTOM), which I do not want to log of course, as they just blow up the file
>> size. (Instead of the binary attachment transmission I want to add a
>> simple
>> String like <ATTACHMENT REMOVED> or something like this.
>>
>> I already have everything working, except the attachment handling. Here is
>> my code till now. (I have nothing with files or so on, I test it with
>> plain
>> System.out.printlns)
>>
>> public class LoggingHandler extends AbstractHandler {
>>
>>        public InvocationResponse invoke(MessageContext msgCtx) throws
>> AxisFault {
>>
>>                SOAPEnvelope env = msgCtx.getEnvelope();
>>
>>                System.out.println(env.toString());
>>
>>                return InvocationResponse.CONTINUE;
>>
>>        }
>>
>> }
>>
>>
>>
>> So can anyone please help me with extracting the attachments?
>> I would be very glad! ;)
>>
>> (Removing the Attachments with msgCtx.removeAttachment(AttachmentID), does
>> not work!!!)
>>
>> Thanks in Advance for both your time and your knowledge!
>>
>> Greeting
>> Stefan
>> --
>> View this message in context:
>> http://www.nabble.com/Axis2---Handler-to-log-all-messages-without-attachments-tp18938449p18938449.html
>> Sent from the Axis - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
>> For additional commands, e-mail: axis-user-help@ws.apache.org
>>
>>
>
>
> --
> Thilina Gunarathne - http://thilinag.blogspot.com
>



-- 
Thilina Gunarathne - http://thilinag.blogspot.com

Re: Axis2 - Handler to log all messages without attachments

Posted by Thilina Gunarathne <cs...@gmail.com>.
You can try traversing the whole envelope looking for <xop:include> elements
and then detach those elements from the tree.. But doing this will cause the
attachment information in the SOAP envelope to be lost and ur services may
not function properly.

One other thing you can try is to access the SOAP part data handler and log
it's contents. You can do that by getting the soap part part content id
using the Attachments.getSOAPPartContentID() and then using
Attachments.getDataHandler(SOAPPartContentID) to get access to the SOAP part
DataHandler. Then just write the contents of the DataHandler to the output
stream.

You can get access to the Attachments using msgCntx.getAttachmentMap()
method.

thanks,
Thilina

On Mon, Aug 11, 2008 at 10:51 PM, StrongSteve <st...@starkeweb.org> wrote:

>
> Hi Everybody!
>
> I am currently developing an Axis2 Handler that logs all SOAP Messages
> targeted at my server into separate files.
> The problem is, that many of these SOAP Messages contain files (binary
> MTOM), which I do not want to log of course, as they just blow up the file
> size. (Instead of the binary attachment transmission I want to add a simple
> String like <ATTACHMENT REMOVED> or something like this.
>
> I already have everything working, except the attachment handling. Here is
> my code till now. (I have nothing with files or so on, I test it with plain
> System.out.printlns)
>
> public class LoggingHandler extends AbstractHandler {
>
>        public InvocationResponse invoke(MessageContext msgCtx) throws
> AxisFault {
>
>                SOAPEnvelope env = msgCtx.getEnvelope();
>
>                System.out.println(env.toString());
>
>                return InvocationResponse.CONTINUE;
>
>        }
>
> }
>
>
>
> So can anyone please help me with extracting the attachments?
> I would be very glad! ;)
>
> (Removing the Attachments with msgCtx.removeAttachment(AttachmentID), does
> not work!!!)
>
> Thanks in Advance for both your time and your knowledge!
>
> Greeting
> Stefan
> --
> View this message in context:
> http://www.nabble.com/Axis2---Handler-to-log-all-messages-without-attachments-tp18938449p18938449.html
> Sent from the Axis - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>


-- 
Thilina Gunarathne - http://thilinag.blogspot.com