You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Avner Levy <av...@checkpoint.com> on 2012/07/12 17:40:37 UTC
Define WebFault in a different package / namespace than the service
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
RE: Define WebFault in a different package / namespace than the
service
Posted by Avner Levy <av...@checkpoint.com>.
Sorry, The stack I was referring to was:
at org.apache.ws.commons.schema.XmlSchemaCollection.getTypeByQName(XmlSchemaCollection.java:229)
at org.apache.cxf.common.xmlschema.SchemaCollection.getTypeByQName(SchemaCollection.java:109)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.fillInSchemaCrossreferences(ReflectionServiceFactoryBean.java:301)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:269)
- locked <0x1670> (a org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:205)
at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:101)
at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:159)
at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:207)
at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:442)
- locked <0x1678> (a org.apache.cxf.jaxws22.EndpointImpl)
at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:329)
at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:246)
-----Original Message-----
From: Avner Levy [mailto:avner@checkpoint.com]
Sent: Friday, July 13, 2012 10:05 AM
To: 'users@cxf.apache.org'
Subject: RE: Define WebFault in a different package / namespace than the service
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: rouble@gmail.com [mailto:rouble@gmail.com] On Behalf Of rouble
Sent: Thursday, July 12, 2012 8:54 PM
To: users@cxf.apache.org
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 <mc...@gmail.com> 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" <av...@checkpoint.com> 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.
Scanned by Check Point Total Security Gateway.
RE: Define WebFault in a different package / namespace than the
service
Posted by Avner Levy <av...@checkpoint.com>.
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: rouble@gmail.com [mailto:rouble@gmail.com] On Behalf Of rouble
Sent: Thursday, July 12, 2012 8:54 PM
To: users@cxf.apache.org
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 <mc...@gmail.com> 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" <av...@checkpoint.com> 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.
Re: Define WebFault in a different package / namespace than the service
Posted by rouble <r....@gmail.com>.
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 <mc...@gmail.com> wrote:
> Perhaps you might want to look at this article:
>
> http://io.typepad.com/eben_hewitt_on_java/2009/07/using-soap-faults-and-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" <av...@checkpoint.com> 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
>>
Re: Define WebFault in a different package / namespace than the service
Posted by Mark Streit <mc...@gmail.com>.
Perhaps you might want to look at this article:
http://io.typepad.com/eben_hewitt_on_java/2009/07/using-soap-faults-and-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" <av...@checkpoint.com> 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
>