You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Milan Duriancik <md...@gmail.com> on 2010/10/29 15:01:51 UTC

problem with custom fault wsa:Action in CXF 2.3/jaxws 2.2

Hi,

I'm trying to customise the wsa:Action for some fault messages using the
contract first approach.
So, first I add to the wsdl:fault element, a wsam:Action attribute (tested
on the CustomerService cxf sample):

...
<wsdl:portType... >
  <wsdl:opertion ...>
     <wsdl:fault  name="NoSuchCustomerException"
                       message="tns:NoSuchCustomerException"
                       wsam:Action="uri:customFaultAction"/> ...

Generating the java code with maven plugin, I get the operation annotated
with:

@Action(fault = {@FaultAction(className = NoSuchCustomerException.class,
value = "uri:customFaultAction")})
     ...

and the fault exception annotated with:

@WebFault(name = "NoSuchCustomer", targetNamespace = "
http://customerservice.example.com/")
public class NoSuchCustomerException extends Exception {
...


It seems greate ...nevertheless when executing the falt message is sent with
the default wsa:Action and the annotation seems to be ignored :-(


Am I missunderstanding somthing? Is there an option or a wsdl element
somewhere I should use to get it working?


Investigating further, I found :


When faultInfo is created (ReflectionServiceFactoryBean.addFault)

    FaultInfo fi = op.addFault(new QName(op.getName().getNamespaceURI(),
faultMsgName), new QName(op.getName().getNamespaceURI(), faultMsgName))

and the variable faultMsgName defaults to the exception class name (because
there's no messageName in @WebFault)

(=> FaultInfo.name==FaultInfo.messageName == fault exception class name)

But when MAPAgregator is trying to determine actionUri, it is comparing
faultName from the actual message and faultName from the FaultInfo which are
not same (NoSuchCustomer != NoSuchCustomerException) => and so it does not
use the FaultInfo to build wsa:Action but uses the default.


If this is a bug I see 2 possible solutions:

1) to initialise faultInfo with WebFault.name and WebFault.messageName,
rather than 2x faultMsgName:

            (simplified:) op.addFault(  WebFault.name,  faultMsgName )

  (?? )

2) to generate (wsdl4j) @WebFault with messageName parameter

@WebFault(name = "NoSuchCustomer", targetNamespace = "
http://customerservice.example.com/", messageName="NoSuchCustomer")

( I've tested adding the annotations manualy and this solves temporarily my
problème)


If I am not wrong and this is a bug I can report the issue in Jira.


Milan

Re: problem with custom fault wsa:Action in CXF 2.3/jaxws 2.2

Posted by Milan Duriancik <md...@gmail.com>.
I've tested with a jdk 1.5 with jaxws 2.2 & jaxb 2.2 maven dependencies
and with a jdk 1.6.0_20 with endorsed jars, but it didn't help.

(geronimo-ws-metadata_2.0_spec-1.1.3.jar, geronimo-jaxws_2.2_spec-1.0.jar,
jaxb-api-2.2.1.jar, jaxb-impl-2.2.1.1.jar, jaxb-xjc-2.2.1.1.jar)

Milan


On Fri, Oct 29, 2010 at 10:01 PM, Daniel Kulp <dk...@apache.org> wrote:

>
> You definitely aren't wrong about this.   Thus, it is a bug that should be
> logged.
>
> Can you check what CXF generates if you endorse the jaxws 2.2 api jar?
> It's
> possible it's not seeing the 2.2 api and thus not outputting the
> messageName
> param.
>
> That said, in the case where messageName isn't there, we probably should go
> with your first solution if that completely works.  Anyway, please log a
> bug.
>
>
> Dan
>
>
>
> On Friday 29 October 2010 9:01:51 am Milan Duriancik wrote:
> > Hi,
> >
> > I'm trying to customise the wsa:Action for some fault messages using the
> > contract first approach.
> > So, first I add to the wsdl:fault element, a wsam:Action attribute
> (tested
> > on the CustomerService cxf sample):
> >
> > ...
> > <wsdl:portType... >
> >   <wsdl:opertion ...>
> >      <wsdl:fault  name="NoSuchCustomerException"
> >                        message="tns:NoSuchCustomerException"
> >                        wsam:Action="uri:customFaultAction"/> ...
> >
> > Generating the java code with maven plugin, I get the operation annotated
> > with:
> >
> > @Action(fault = {@FaultAction(className = NoSuchCustomerException.class,
> > value = "uri:customFaultAction")})
> >      ...
> >
> > and the fault exception annotated with:
> >
> > @WebFault(name = "NoSuchCustomer", targetNamespace = "
> > http://customerservice.example.com/")
> > public class NoSuchCustomerException extends Exception {
> > ...
> >
> >
> > It seems greate ...nevertheless when executing the falt message is sent
> > with the default wsa:Action and the annotation seems to be ignored :-(
> >
> >
> > Am I missunderstanding somthing? Is there an option or a wsdl element
> > somewhere I should use to get it working?
> >
> >
> > Investigating further, I found :
> >
> >
> > When faultInfo is created (ReflectionServiceFactoryBean.addFault)
> >
> >     FaultInfo fi = op.addFault(new QName(op.getName().getNamespaceURI(),
> > faultMsgName), new QName(op.getName().getNamespaceURI(), faultMsgName))
> >
> > and the variable faultMsgName defaults to the exception class name
> (because
> > there's no messageName in @WebFault)
> >
> > (=> FaultInfo.name==FaultInfo.messageName == fault exception class name)
> >
> > But when MAPAgregator is trying to determine actionUri, it is comparing
> > faultName from the actual message and faultName from the FaultInfo which
> > are not same (NoSuchCustomer != NoSuchCustomerException) => and so it
> does
> > not use the FaultInfo to build wsa:Action but uses the default.
> >
> >
> > If this is a bug I see 2 possible solutions:
> >
> > 1) to initialise faultInfo with WebFault.name and WebFault.messageName,
> > rather than 2x faultMsgName:
> >
> >             (simplified:) op.addFault(  WebFault.name,  faultMsgName )
> >
> >   (?? )
> >
> > 2) to generate (wsdl4j) @WebFault with messageName parameter
> >
> > @WebFault(name = "NoSuchCustomer", targetNamespace = "
> > http://customerservice.example.com/", messageName="NoSuchCustomer")
> >
> > ( I've tested adding the annotations manualy and this solves temporarily
> my
> > problème)
> >
> >
> > If I am not wrong and this is a bug I can report the issue in Jira.
> >
> >
> > Milan
>
> --
> Daniel Kulp
> dkulp@apache.org
> http://dankulp.com/blog
>

Re: problem with custom fault wsa:Action in CXF 2.3/jaxws 2.2

Posted by Daniel Kulp <dk...@apache.org>.
You definitely aren't wrong about this.   Thus, it is a bug that should be 
logged.

Can you check what CXF generates if you endorse the jaxws 2.2 api jar?   It's 
possible it's not seeing the 2.2 api and thus not outputting the messageName 
param.

That said, in the case where messageName isn't there, we probably should go 
with your first solution if that completely works.  Anyway, please log a bug.


Dan



On Friday 29 October 2010 9:01:51 am Milan Duriancik wrote:
> Hi,
> 
> I'm trying to customise the wsa:Action for some fault messages using the
> contract first approach.
> So, first I add to the wsdl:fault element, a wsam:Action attribute (tested
> on the CustomerService cxf sample):
> 
> ...
> <wsdl:portType... >
>   <wsdl:opertion ...>
>      <wsdl:fault  name="NoSuchCustomerException"
>                        message="tns:NoSuchCustomerException"
>                        wsam:Action="uri:customFaultAction"/> ...
> 
> Generating the java code with maven plugin, I get the operation annotated
> with:
> 
> @Action(fault = {@FaultAction(className = NoSuchCustomerException.class,
> value = "uri:customFaultAction")})
>      ...
> 
> and the fault exception annotated with:
> 
> @WebFault(name = "NoSuchCustomer", targetNamespace = "
> http://customerservice.example.com/")
> public class NoSuchCustomerException extends Exception {
> ...
> 
> 
> It seems greate ...nevertheless when executing the falt message is sent
> with the default wsa:Action and the annotation seems to be ignored :-(
> 
> 
> Am I missunderstanding somthing? Is there an option or a wsdl element
> somewhere I should use to get it working?
> 
> 
> Investigating further, I found :
> 
> 
> When faultInfo is created (ReflectionServiceFactoryBean.addFault)
> 
>     FaultInfo fi = op.addFault(new QName(op.getName().getNamespaceURI(),
> faultMsgName), new QName(op.getName().getNamespaceURI(), faultMsgName))
> 
> and the variable faultMsgName defaults to the exception class name (because
> there's no messageName in @WebFault)
> 
> (=> FaultInfo.name==FaultInfo.messageName == fault exception class name)
> 
> But when MAPAgregator is trying to determine actionUri, it is comparing
> faultName from the actual message and faultName from the FaultInfo which
> are not same (NoSuchCustomer != NoSuchCustomerException) => and so it does
> not use the FaultInfo to build wsa:Action but uses the default.
> 
> 
> If this is a bug I see 2 possible solutions:
> 
> 1) to initialise faultInfo with WebFault.name and WebFault.messageName,
> rather than 2x faultMsgName:
> 
>             (simplified:) op.addFault(  WebFault.name,  faultMsgName )
> 
>   (?? )
> 
> 2) to generate (wsdl4j) @WebFault with messageName parameter
> 
> @WebFault(name = "NoSuchCustomer", targetNamespace = "
> http://customerservice.example.com/", messageName="NoSuchCustomer")
> 
> ( I've tested adding the annotations manualy and this solves temporarily my
> problème)
> 
> 
> If I am not wrong and this is a bug I can report the issue in Jira.
> 
> 
> Milan

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