Hi

On Wed, Aug 3, 2011 at 3:44 PM, [email protected] <[email protected]> wrote:
> Thanks again for your answer Sergey,
>
> That is not possible right now - you'll need to use a custom handler
>> to get conditional drops working
>>
>
> You suggest I go back to the Interceptor solution then (custom handler =
> custom Interceptor?)?
> I was at the stage where I could get the message in my custom outbound
> Interceptor but I still don't know how to modify the SOAP request from
> there. So if we look again at my current code for the Interceptor:
>
> public class MyOutInterceptor extends AbstractSoapInterceptor {
>
> public MyOutInterceptor() {
>        super(Phase.SEND);
> }
>
> public void handleMessage(SoapMessage message) throws Fault {
>        // Get message content for editing...
>        StringWriter writer = new StringWriter();
>        CachedOutputStream cos  =
> (CachedOutputStream)message.getContent(OutputStream.class);
>        InputStream inputStream = cos.getInputStream();
>        IOUtils.copy(inputStream, writer, "UTF-8");
>        String content = writer.toString();
>
>        // remove the substrings from envelope if necessary...
>        if (content.contains("<typeEnvoi>2</typeEnvoi>")) {
>            content =
> content.replace("<idJustification>0</idJustification>", "");
>            content = content.replace("<indicRdv>false</indicRdv>", "");
>            ByteArrayOutputStream outputStream = new
> ByteArrayOutputStream();
>            outputStream.write(content.getBytes(Charset.forName("UTF-8")));
>                }
>        message.setContent(OutputStream.class, outputStream);
>     }
> }
>
> How could I modify the enveloppe by simply removing the unwanted XML tags
> and then proceed with the actual sending of the message? Modifying the
> message as a String is not the best solution I guess but I don't know how to
> manipulate the SOAPMessage to achieve that...
>

me neither :-) Creating a custom XMLStreamWriter is one option, but
SOAPMessage modification would definitely be simpler
if it's possible to do at the interceptor level
>
>
>> Use outDropElements list property, just list "indicRdv" and
>> "idJustification". If they were qualified then you'd use
>> "{http://example.mytests.com/}indicRdv";, etc...
>>
>
> Ok I used outDropElements and it seems to drop the right elements, but one
> consequence of using the TransformOutInterceptor is that the Outbound
> message is not logged anymore si I can't see what is really sent (using the
> LoggingOutInterceptor)...
>
That must be the issue in 2.4.0 - 2.4.1 should log ok. You can use tcp
trace too...

Cheers, Sergey

> Sorry for my "newbie" questions but I appreciated your help.
> Toutcon
>
>
>
>
>
>>> On Tue, Aug 2, 2011 at 20:36, Sergey Beryozkin-5 [via CXF] <
>>> [hidden email] <http://user/SendEmail.jtp?type=node&node=4662049&i=2>>
> wrote:
>>>
>>>> Hi
>>>>
>>>> Have a look please at Transform feature, that should be achieved
>>>> easily enough by
>>>> configuring outDropElements property.
>>>> http://cxf.apache.org/docs/transformationfeature.html
>>>> In CXF 2.4.1 one has to list all elements to be dropped, which should
>>>> be ok for your case, looks like
>>>> two simple element siblings need to be dropped;
>>>> Aki added a support for deep drops too for incoming payloads, will be
>>>> available in 2.4.2; sooner rather later the out transform writer will
>>>> follow the suit :-)
>>>>
>>>> Cheers, Sergey
>>>>
>>>> On Tue, Aug 2, 2011 at 6:47 PM, [hidden email]<
> http://user/SendEmail.jtp?type=node&node=4659881&i=0><[hidden
>>>> email] <http://user/SendEmail.jtp?type=node&node=4659881&i=1>> wrote:
>>>>
>>>> > Hi everyone (this is my first post on this mailing-list)
>>>> >
>>>> > I would like to modify an outgoing SOAP Request. I would like to
> remove
>>>> 2
>>>> > xml nodes from the Envelope's body. I managed to set up an Interceptor
>
>>>> and
>>>> > get the generated String value of the message set to the endpoint.
>>>> >
>>>> > However, the following code does not seem to work as the outgoing
>>>> message is
>>>> > not edited as expected. Does anyone have some code or ideas on how to
> do
>>>>
>>>> > this?
>>>> >
>>>> > public class MyOutInterceptor extends AbstractSoapInterceptor {
>>>> >
>>>> > public MyOutInterceptor() {
>>>> >        super(Phase.SEND);
>>>> > }
>>>> >
>>>> > public void handleMessage(SoapMessage message) throws Fault {
>>>> >        // Get message content for dirty editing...
>>>> >        StringWriter writer = new StringWriter();
>>>> >        CachedOutputStream cos  =
>>>> > (CachedOutputStream)message.getContent(OutputStream.class);
>>>> >        InputStream inputStream = cos.getInputStream();
>>>> >        IOUtils.copy(inputStream, writer, "UTF-8");
>>>> >        String content = writer.toString();
>>>> >
>>>> >        // remove the substrings from envelope...
>>>> >        content =
> content.replace("<idJustification>0</idJustification>",
>>>>
>>>> > "");
>>>> >        content = content.replace("<indicRdv>false</indicRdv>", "");
>>>> >        ByteArrayOutputStream outputStream = new
> ByteArrayOutputStream();
>>>>
>>>> >        outputStream.write(content.getBytes(Charset.forName("UTF-8")));
>
>>>> >        message.setContent(OutputStream.class, outputStream);
>>>> > }
>>>> >
>>>> > Am I missing something? What is a better way to to this?
>>>> > It seems too complicated to achieve my pretty simple requirement...
>>>> >
>>>>
>>>>
>>>>
>>>> --
>>>> Sergey Beryozkin
>>>>
>>>> http://sberyozkin.blogspot.com
>>>> Talend - http://www.talend.com
>>>>
>>>>
>>>> ------------------------------
>>>>  If you reply to this email, your message will be added to the
> discussion
>>>> below:
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>
>
>
> --
> Sergey Beryozkin
>
> http://sberyozkin.blogspot.com
> Talend - http://www.talend.com
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
> http://cxf.547215.n5.nabble.com/How-To-Modify-The-Raw-XML-message-of-an-Outbound-CXF-Request-tp4659707p4662049.html
>  To unsubscribe from cxf-user, click
> here<http://cxf.547215.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=547216&code=dG91dGNvbkBnbWFpbC5jb218NTQ3MjE2fC03MjM4ODg4OTM=>.
>



-- 
Sergey Beryozkin

http://sberyozkin.blogspot.com
Talend - http://www.talend.com

Reply via email to