You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Steffen Schäffner <st...@seetec.de> on 2011/04/26 13:50:03 UTC

CXF and SOAP

Hello there,

I have some more questions about CXF.

I am using CXF 2.4.0.


1.       If I don't use an authorization, no header will be added to the SOAP message. How can I change that? If no header is within, I will get an error from my server.

2.       How can I print/save/use the outgoing/incoming SOAP messages? For example if I get an error I want to log the outgoing/incoming SOAP messages. Where to set/select this?

Thank you!

Best regards,

Steffen Schäffner


Re: AW: CXF and SOAP

Posted by Daniel Kulp <dk...@apache.org>.
On Wednesday, April 27, 2011 3:17:40 AM Steffen Schäffner wrote:
> If I use this
> 
> 	factory.getInInterceptors().add(new LoggingInInterceptor());
> 	factory.getOutInterceptors().add(new LoggingOutInterceptor());
> 
> instead of this
> 
> 	final LoggingOutInterceptor loggingOutInterceptor = new
> LoggingOutInterceptor(); final LoggingInInterceptor loggingInInterceptor =
> new LoggingInInterceptor();
> 
> 	factory.getInInterceptors().add(loggingOutInterceptor);
> 	factory.getOutInterceptors().add(loggingInInterceptor);

You are adding the "Out" interceptor to the in chain and the "In" interceptor 
to the out chain.   A little mismatch.   :-)

Dan



> 
> it works. Don't know why.
> 
> Is it possible the given output write to a log4j instance?
> 
> -----Ursprüngliche Nachricht-----
> Von: Steffen Schäffner [mailto:steffen.schaeffner@seetec.de]
> Gesendet: Mittwoch, 27. April 2011 08:57
> An: users@cxf.apache.org
> Betreff: AW: CXF and SOAP
> 
> Thank you for your answers.
> 
> I tried to work with interceptors, but I always get some warnings when I
> receive/send a message.
> 
> I added the following to my code:
> 
> 	final LoggingOutInterceptor loggingOutInterceptor = new
> LoggingOutInterceptor(); final LoggingInInterceptor loggingInInterceptor =
> new LoggingInInterceptor();
> 
> 	loggingOutInterceptor.setPrettyLogging(true);
> 	loggingInInterceptor.setPrettyLogging(true);
> 
> 	this.factory.getInInterceptors().add(loggingOutInterceptor);
> 	this.factory.getOutInterceptors().add(loggingInInterceptor);
> 
> I always get the following response:
> 
> 27.04.2011 08:53:18 org.apache.cxf.phase.PhaseInterceptorChain add
> WARNUNG: Skipping interceptor
> org.apache.cxf.interceptor.LoggingInInterceptor: Phase receive specified
> does not exist. 27.04.2011 08:53:18
> org.apache.cxf.phase.PhaseInterceptorChain add WARNUNG: Skipping
> interceptor org.apache.cxf.interceptor.LoggingInInterceptor: Phase receive
> specified does not exist.
> 
> Can anybody help?
> 
> If this works, is it possible to send the logging messages in a logging
> output, for example log4j?
> 
> -----Ursprüngliche Nachricht-----
> Von: Emil Dombagolla [mailto:dombagolla@gmail.com]
> Gesendet: Mittwoch, 27. April 2011 07:44
> An: users@cxf.apache.org
> Betreff: Re: CXF and SOAP
> 
> Hi ,
> 
> Sometimes this may helpful to you.
> 
> regarding headers
> 
> http://cxf.apache.org/faq.html#FAQ-HowcanIaddsoapheaderstotherequest%2Fresp
> onse%3F
> 
> and for logging , best way to implement interceptor , that is what i am
> also doing now.
> 
> http://cxf.apache.org/docs/interceptors.html
> 
> or if looking to do something by your hand , this is the place to look for
> in the src.
> 
> org.apache.cxf.interceptor.LoggingMessage
> 
> thanks
> D
> 
> On Tue, Apr 26, 2011 at 7:27 PM, KARR, DAVID (ATTSI) <dk...@att.com> wrote:
> > > -----Original Message-----
> > > From: Steffen Schäffner [mailto:steffen.schaeffner@seetec.de]
> > > Sent: Tuesday, April 26, 2011 4:50 AM
> > > To: users@cxf.apache.org
> > > Subject: CXF and SOAP
> > > 
> > > Hello there,
> > > 
> > > I have some more questions about CXF.
> > > 
> > > I am using CXF 2.4.0.
> > > 
> > > 
> > > 1.       If I don't use an authorization, no header will be added to
> > > the SOAP message. How can I change that? If no header is within, I will
> > > get an error from my server.
> > 
> > I assume you've confirmed this, not just guessing that you'll get an
> > error?
> > 
> >  The Soap schema specifies that the header is optional, so a server that
> > 
> > gives a specific error saying the header is missing, is defective.
> > 
> > Years ago, I noticed that the Websphere web services infrastructure would
> > throw an NPE if a Soap header was not present.  Are you using Websphere
> > on the server, by any chance?

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

AW: CXF and SOAP

Posted by Steffen Schäffner <st...@seetec.de>.
If I use this

	factory.getInInterceptors().add(new LoggingInInterceptor());
	factory.getOutInterceptors().add(new LoggingOutInterceptor());

instead of this

	final LoggingOutInterceptor loggingOutInterceptor = new LoggingOutInterceptor();
	final LoggingInInterceptor loggingInInterceptor = new LoggingInInterceptor();

	factory.getInInterceptors().add(loggingOutInterceptor);
	factory.getOutInterceptors().add(loggingInInterceptor);

it works. Don't know why.

Is it possible the given output write to a log4j instance?

-----Ursprüngliche Nachricht-----
Von: Steffen Schäffner [mailto:steffen.schaeffner@seetec.de] 
Gesendet: Mittwoch, 27. April 2011 08:57
An: users@cxf.apache.org
Betreff: AW: CXF and SOAP

Thank you for your answers.

I tried to work with interceptors, but I always get some warnings when I receive/send a message.

I added the following to my code:

	final LoggingOutInterceptor loggingOutInterceptor = new LoggingOutInterceptor();
	final LoggingInInterceptor loggingInInterceptor = new LoggingInInterceptor();

	loggingOutInterceptor.setPrettyLogging(true);
	loggingInInterceptor.setPrettyLogging(true);

	this.factory.getInInterceptors().add(loggingOutInterceptor);
	this.factory.getOutInterceptors().add(loggingInInterceptor);

I always get the following response:

27.04.2011 08:53:18 org.apache.cxf.phase.PhaseInterceptorChain add
WARNUNG: Skipping interceptor org.apache.cxf.interceptor.LoggingInInterceptor: Phase receive specified does not exist.
27.04.2011 08:53:18 org.apache.cxf.phase.PhaseInterceptorChain add
WARNUNG: Skipping interceptor org.apache.cxf.interceptor.LoggingInInterceptor: Phase receive specified does not exist.

Can anybody help?

If this works, is it possible to send the logging messages in a logging output, for example log4j?

-----Ursprüngliche Nachricht-----
Von: Emil Dombagolla [mailto:dombagolla@gmail.com] 
Gesendet: Mittwoch, 27. April 2011 07:44
An: users@cxf.apache.org
Betreff: Re: CXF and SOAP

Hi ,

Sometimes this may helpful to you.

regarding headers

http://cxf.apache.org/faq.html#FAQ-HowcanIaddsoapheaderstotherequest%2Fresponse%3F

and for logging , best way to implement interceptor , that is what i am also
doing now.

http://cxf.apache.org/docs/interceptors.html

or if looking to do something by your hand , this is the place to look for
in the src.

org.apache.cxf.interceptor.LoggingMessage

thanks
D


On Tue, Apr 26, 2011 at 7:27 PM, KARR, DAVID (ATTSI) <dk...@att.com> wrote:

> > -----Original Message-----
> > From: Steffen Schäffner [mailto:steffen.schaeffner@seetec.de]
> > Sent: Tuesday, April 26, 2011 4:50 AM
> > To: users@cxf.apache.org
> > Subject: CXF and SOAP
> >
> > Hello there,
> >
> > I have some more questions about CXF.
> >
> > I am using CXF 2.4.0.
> >
> >
> > 1.       If I don't use an authorization, no header will be added to
> > the SOAP message. How can I change that? If no header is within, I will
> > get an error from my server.
>
> I assume you've confirmed this, not just guessing that you'll get an error?
>  The Soap schema specifies that the header is optional, so a server that
> gives a specific error saying the header is missing, is defective.
>
> Years ago, I noticed that the Websphere web services infrastructure would
> throw an NPE if a Soap header was not present.  Are you using Websphere on
> the server, by any chance?
>


Re: CXF and SOAP

Posted by Emil Dombagolla <do...@gmail.com>.
Hi ,

Did you try *cfx.xml* file by putting to your classpath.

I have attached my config file this enables me logging on console. No need
any programmatic access for those interceptors.

Emil


2011/4/27 Steffen Sch�ffner <st...@seetec.de>

> Thank you for your answers.
>
> I tried to work with interceptors, but I always get some warnings when I
> receive/send a message.
>
> I added the following to my code:
>
>        final LoggingOutInterceptor loggingOutInterceptor = new
> LoggingOutInterceptor();
>        final LoggingInInterceptor loggingInInterceptor = new
> LoggingInInterceptor();
>
>        loggingOutInterceptor.setPrettyLogging(true);
>        loggingInInterceptor.setPrettyLogging(true);
>
>        this.factory.getInInterceptors().add(loggingOutInterceptor);
>        this.factory.getOutInterceptors().add(loggingInInterceptor);
>
> I always get the following response:
>
> 27.04.2011 08:53:18 org.apache.cxf.phase.PhaseInterceptorChain add
> WARNUNG: Skipping interceptor
> org.apache.cxf.interceptor.LoggingInInterceptor: Phase receive specified
> does not exist.
> 27.04.2011 08:53:18 org.apache.cxf.phase.PhaseInterceptorChain add
> WARNUNG: Skipping interceptor
> org.apache.cxf.interceptor.LoggingInInterceptor: Phase receive specified
> does not exist.
>
> Can anybody help?
>
> If this works, is it possible to send the logging messages in a logging
> output, for example log4j?
>
> -----Urspr�ngliche Nachricht-----
> Von: Emil Dombagolla [mailto:dombagolla@gmail.com]
> Gesendet: Mittwoch, 27. April 2011 07:44
> An: users@cxf.apache.org
> Betreff: Re: CXF and SOAP
>
> Hi ,
>
> Sometimes this may helpful to you.
>
> regarding headers
>
>
> http://cxf.apache.org/faq.html#FAQ-HowcanIaddsoapheaderstotherequest%2Fresponse%3F
>
> and for logging , best way to implement interceptor , that is what i am
> also
> doing now.
>
> http://cxf.apache.org/docs/interceptors.html
>
> or if looking to do something by your hand , this is the place to look for
> in the src.
>
> org.apache.cxf.interceptor.LoggingMessage
>
> thanks
> D
>
>
> On Tue, Apr 26, 2011 at 7:27 PM, KARR, DAVID (ATTSI) <dk...@att.com>
> wrote:
>
> > > -----Original Message-----
> > > From: Steffen Sch�ffner [mailto:steffen.schaeffner@seetec.de]
> > > Sent: Tuesday, April 26, 2011 4:50 AM
> > > To: users@cxf.apache.org
> > > Subject: CXF and SOAP
> > >
> > > Hello there,
> > >
> > > I have some more questions about CXF.
> > >
> > > I am using CXF 2.4.0.
> > >
> > >
> > > 1.       If I don't use an authorization, no header will be added to
> > > the SOAP message. How can I change that? If no header is within, I will
> > > get an error from my server.
> >
> > I assume you've confirmed this, not just guessing that you'll get an
> error?
> >  The Soap schema specifies that the header is optional, so a server that
> > gives a specific error saying the header is missing, is defective.
> >
> > Years ago, I noticed that the Websphere web services infrastructure would
> > throw an NPE if a Soap header was not present.  Are you using Websphere
> on
> > the server, by any chance?
> >
>

AW: CXF and SOAP

Posted by Steffen Schäffner <st...@seetec.de>.
Thank you for your answers.

I tried to work with interceptors, but I always get some warnings when I receive/send a message.

I added the following to my code:

	final LoggingOutInterceptor loggingOutInterceptor = new LoggingOutInterceptor();
	final LoggingInInterceptor loggingInInterceptor = new LoggingInInterceptor();

	loggingOutInterceptor.setPrettyLogging(true);
	loggingInInterceptor.setPrettyLogging(true);

	this.factory.getInInterceptors().add(loggingOutInterceptor);
	this.factory.getOutInterceptors().add(loggingInInterceptor);

I always get the following response:

27.04.2011 08:53:18 org.apache.cxf.phase.PhaseInterceptorChain add
WARNUNG: Skipping interceptor org.apache.cxf.interceptor.LoggingInInterceptor: Phase receive specified does not exist.
27.04.2011 08:53:18 org.apache.cxf.phase.PhaseInterceptorChain add
WARNUNG: Skipping interceptor org.apache.cxf.interceptor.LoggingInInterceptor: Phase receive specified does not exist.

Can anybody help?

If this works, is it possible to send the logging messages in a logging output, for example log4j?

-----Ursprüngliche Nachricht-----
Von: Emil Dombagolla [mailto:dombagolla@gmail.com] 
Gesendet: Mittwoch, 27. April 2011 07:44
An: users@cxf.apache.org
Betreff: Re: CXF and SOAP

Hi ,

Sometimes this may helpful to you.

regarding headers

http://cxf.apache.org/faq.html#FAQ-HowcanIaddsoapheaderstotherequest%2Fresponse%3F

and for logging , best way to implement interceptor , that is what i am also
doing now.

http://cxf.apache.org/docs/interceptors.html

or if looking to do something by your hand , this is the place to look for
in the src.

org.apache.cxf.interceptor.LoggingMessage

thanks
D


On Tue, Apr 26, 2011 at 7:27 PM, KARR, DAVID (ATTSI) <dk...@att.com> wrote:

> > -----Original Message-----
> > From: Steffen Schäffner [mailto:steffen.schaeffner@seetec.de]
> > Sent: Tuesday, April 26, 2011 4:50 AM
> > To: users@cxf.apache.org
> > Subject: CXF and SOAP
> >
> > Hello there,
> >
> > I have some more questions about CXF.
> >
> > I am using CXF 2.4.0.
> >
> >
> > 1.       If I don't use an authorization, no header will be added to
> > the SOAP message. How can I change that? If no header is within, I will
> > get an error from my server.
>
> I assume you've confirmed this, not just guessing that you'll get an error?
>  The Soap schema specifies that the header is optional, so a server that
> gives a specific error saying the header is missing, is defective.
>
> Years ago, I noticed that the Websphere web services infrastructure would
> throw an NPE if a Soap header was not present.  Are you using Websphere on
> the server, by any chance?
>

Re: CXF and SOAP

Posted by Emil Dombagolla <do...@gmail.com>.
Hi ,

Sometimes this may helpful to you.

regarding headers

http://cxf.apache.org/faq.html#FAQ-HowcanIaddsoapheaderstotherequest%2Fresponse%3F

and for logging , best way to implement interceptor , that is what i am also
doing now.

http://cxf.apache.org/docs/interceptors.html

or if looking to do something by your hand , this is the place to look for
in the src.

org.apache.cxf.interceptor.LoggingMessage

thanks
D


On Tue, Apr 26, 2011 at 7:27 PM, KARR, DAVID (ATTSI) <dk...@att.com> wrote:

> > -----Original Message-----
> > From: Steffen Schäffner [mailto:steffen.schaeffner@seetec.de]
> > Sent: Tuesday, April 26, 2011 4:50 AM
> > To: users@cxf.apache.org
> > Subject: CXF and SOAP
> >
> > Hello there,
> >
> > I have some more questions about CXF.
> >
> > I am using CXF 2.4.0.
> >
> >
> > 1.       If I don't use an authorization, no header will be added to
> > the SOAP message. How can I change that? If no header is within, I will
> > get an error from my server.
>
> I assume you've confirmed this, not just guessing that you'll get an error?
>  The Soap schema specifies that the header is optional, so a server that
> gives a specific error saying the header is missing, is defective.
>
> Years ago, I noticed that the Websphere web services infrastructure would
> throw an NPE if a Soap header was not present.  Are you using Websphere on
> the server, by any chance?
>

AW: CXF and SOAP

Posted by Steffen Schäffner <st...@seetec.de>.
If I send a message via soapUI without a header element, I always get the following answer from the server:

<HTML>
   <HEAD>
      <TITLE>502 Bad Gateway</TITLE>
   </HEAD>
   <BODY>
      <H1>502 Bad Gateway</H1>
      The CGI was not CGI/1.1 compliant.
   </BODY>
</HTML>

If I add the element again, it works. With my CXF implementation I also have no header. I checked this by wireshark.

I am not using Websphere.

Thank you!

-----Ursprüngliche Nachricht-----
Von: KARR, DAVID (ATTSI) [mailto:dk068x@att.com] 
Gesendet: Dienstag, 26. April 2011 15:58
An: users@cxf.apache.org
Betreff: RE: CXF and SOAP

> -----Original Message-----
> From: Steffen Schäffner [mailto:steffen.schaeffner@seetec.de]
> Sent: Tuesday, April 26, 2011 4:50 AM
> To: users@cxf.apache.org
> Subject: CXF and SOAP
> 
> Hello there,
> 
> I have some more questions about CXF.
> 
> I am using CXF 2.4.0.
> 
> 
> 1.       If I don't use an authorization, no header will be added to
> the SOAP message. How can I change that? If no header is within, I will
> get an error from my server.

I assume you've confirmed this, not just guessing that you'll get an error?  The Soap schema specifies that the header is optional, so a server that gives a specific error saying the header is missing, is defective.

Years ago, I noticed that the Websphere web services infrastructure would throw an NPE if a Soap header was not present.  Are you using Websphere on the server, by any chance?


RE: CXF and SOAP

Posted by "KARR, DAVID (ATTSI)" <dk...@att.com>.
> -----Original Message-----
> From: Steffen Schäffner [mailto:steffen.schaeffner@seetec.de]
> Sent: Tuesday, April 26, 2011 4:50 AM
> To: users@cxf.apache.org
> Subject: CXF and SOAP
> 
> Hello there,
> 
> I have some more questions about CXF.
> 
> I am using CXF 2.4.0.
> 
> 
> 1.       If I don't use an authorization, no header will be added to
> the SOAP message. How can I change that? If no header is within, I will
> get an error from my server.

I assume you've confirmed this, not just guessing that you'll get an error?  The Soap schema specifies that the header is optional, so a server that gives a specific error saying the header is missing, is defective.

Years ago, I noticed that the Websphere web services infrastructure would throw an NPE if a Soap header was not present.  Are you using Websphere on the server, by any chance?

Re: CXF and SOAP

Posted by Aki Yoshida <el...@googlemail.com>.
Hi,
1. There is a good online documentation at
http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html
that describes how to set the authentication header, namely by setting
the UserName and Password properties for your http conduit.

2. If you just want to log each message, you can just use the logging
feature (i.e., adding <cxf:logging> under <cxf:features> in the cxf
bus configuration) or inserting the logging interceptors manually. The
logging interceptors simply write the passing messages to the log. If
you want to conditionally log the message to some specific output
location, you will need to write your own interceptor.
org.apache.cxf.interceptor.LoggingOutInterceptor will be a good
starting point.

Regards, aki

2011/4/26 Steffen Schäffner <st...@seetec.de>:
> Hello there,
>
> I have some more questions about CXF.
>
> I am using CXF 2.4.0.
>
>
> 1.       If I don't use an authorization, no header will be added to the SOAP message. How can I change that? If no header is within, I will get an error from my server.
>
> 2.       How can I print/save/use the outgoing/incoming SOAP messages? For example if I get an error I want to log the outgoing/incoming SOAP messages. Where to set/select this?
>
> Thank you!
>
> Best regards,
>
> Steffen Schäffner
>
>