Thanks guys for the help.
I think controlling the namespace of the web fault and fault bean worked fine
on my case.
I've defined the following annotation:
@WebFault(name = "GeneralRemoteFault", targetNamespace = MY_NAMESPACE)
And it was generated into a different namespace in the WSDL (and wire).
Controlling of the Fault bean wasn't a problem as well since it is a JAXB
object, I just added the package namespace in the package-info.java file and it
works fine as well.
I read several times the excellent blog
http://io.typepad.com/eben_hewitt_on_java/2009/07/using-soap-faults-and-exceptions-in-java-jaxws-web-services.html
and followed his guidelines.
In additional I've run the wsimport tool to generate the java code from the
wsdl and it generated a very similar code to the one I've written.
After debugging the code which run the service I've noticed that in the
following stack:
initializedServiceModel->buildServiceFromClass->initialize->walk->visitOperation->begin()->getTypeByName->getTypeByQName
The schema collection (XmlSchemaCollection.schemas) doesn't include the
namespace of the fault bean and that is why it fails (only the service one's
and the fault one's).
It seems that CXF doesn't take into account the option that the fault bean will
be defined in a separate namespace than the others and doesn't loads the fault
bean schema into the schema collection.
Even if I put the fault bean together in the same namespace with the fault, the
schema (XmlSchema) for the namespace won't include the JAXB types only the
faults.
I've tried to add the fault beans with @XmlSeeAlso on the service interface but
it didn't help.
Any ideas?
Thanks again,
Avner
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of rouble
Sent: Thursday, July 12, 2012 8:54 PM
To: [email protected]
Subject: Re: Define WebFault in a different package / namespace than the service
I had a very similar question a couple days ago. I have been unable to get the
exception in a different namespace. I can change the name space of the fault
bean (return value of getFaultnfo()), but I can not affect the name space of
the web fault itself.
In the mail archives look for the thread titled 'Exceptions ignore namespace
configuration' - if you want to see the discussion thread around my issue:
http://mail-archives.apache.org/mod_mbox/cxf-users/201207.mbox/browser
Either I am missing something or this is a deficiency of CXF.
cheers
rouble
On Thu, Jul 12, 2012 at 1:35 PM, Mark Streit <[email protected]> wrote:
> Perhaps you might want to look at this article:
>
> http://io.typepad.com/eben_hewitt_on_java/2009/07/using-soap-faults-an
> d-exceptions-in-java-jaxws-web-services.html
>
> ....just to make sure the annotations are correct.
>
> Mark
> On Jul 12, 2012 11:41 AM, "Avner Levy" <[email protected]> wrote:
>
>> Hi,
>> I'm using jax-ws with cxf implementation to implement web services.
>> I have several services annotated with the @WebService annotation.
>> In a different package I defined the exceptions (which inherit from
>> RuntimeException) and annotated them with @WebFault with a unique namespace.
>> Each exception class holds a single bean with the exception data
>> (faultInfo) which resides in the same namespace and package as the
>> fault and is annotated with @XMlType.
>> When I run the server CXF complain with the following error:
>>
>> ERROR
>> org.apache.cxf.service.factory.ReflectionServiceFactoryBean.fillInSchemaCrossreferences:305
>> [main] - Schema element {
>> http://www.example.com/schema}ValidationRemoteFault references
>> undefined type
>> {http://www.example.com/schema}ValidationRemoteFaultException for
>> service {http://web_services.example.com/}ValidationService
>>
>> The ValidationRemoteFault is the class annotated with the WebFault
>> and ValidationRemoteFaultException is the bean class annotated with XmlType.
>>
>> Any insight about solving the error will be appreciated.
>>
>> Thanks,
>> Avner
>>
Scanned by Check Point Total Security Gateway.