You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Arne Welzel <ar...@googlemail.com> on 2010/04/07 18:21:36 UTC

wsdl2java using jaxb and multiple schemes, Marshaling Exeption

Hi all,

i have a question regarding wsdl2java using JAXBRI as databinding
option. The wsdl is referencing two "somewhat" independent schema files.

I'm describing the problem in general as I'm not allowed to publish the
used files. If needed I can construct an example which should show the
observed problem.

We have the following situation:
 - wsdl containing message definitions which reference elements
   from our first schema.

 - One of the types given in the first schema uses xsd:Any.
   This is where the second schema file comes into play.

 - Every element defined in the second schema may be put where xsd:Any
   is used. (This is the dependency between those schemas). Besides
   the elements given in the second schema everything else might be
   used, those are some "known" elements.

When running wsdl2java, classes for the elements in the second schema
are generated. However using those classes and putting them into the
xsd:Any position ( obj.getAny().add(objectofgeneratedclass) ) leads to a
MarshalException / JAXBException saying "<class>  nor any of its super
class is known to this context".

I was able to solve this by adding the generated classes to the context
initialization code in the ServiceStub.java file.

It would be interesting to know if there is some flag to simply use
every generated class in the context or if the used fix is acceptable.

Any further comments are welcome.

As mentioned above, if the problem is not clear from the given
description I can try to construct an example and post it.

--
Arne

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


Re: wsdl2java using jaxb and multiple schemes, Marshaling Exeption

Posted by Arne Welzel <ar...@googlemail.com>.

On Thu, 8 Apr 2010, Amila Suriarachchi wrote:

> On Wed, Apr 7, 2010 at 9:51 PM, Arne Welzel <ar...@googlemail.com>wrote:
>
>> Hi all,
>>
>> i have a question regarding wsdl2java using JAXBRI as databinding
>> option. The wsdl is referencing two "somewhat" independent schema files.
>>
>> I'm describing the problem in general as I'm not allowed to publish the
>> used files. If needed I can construct an example which should show the
>> observed problem.
>>
>> We have the following situation:
>>  - wsdl containing message definitions which reference elements
>>   from our first schema.
>>
>>  - One of the types given in the first schema uses xsd:Any.
>>   This is where the second schema file comes into play.
>>
>>  - Every element defined in the second schema may be put where xsd:Any
>>   is used. (This is the dependency between those schemas). Besides
>>   the elements given in the second schema everything else might be
>>   used, those are some "known" elements.
>>
>> When running wsdl2java, classes for the elements in the second schema
>> are generated. However using those classes and putting them into the
>> xsd:Any position ( obj.getAny().add(objectofgeneratedclass) ) leads to a
>> MarshalException / JAXBException saying "<class>  nor any of its super
>> class is known to this context".
>>
>> I was able to solve this by adding the generated classes to the context
>> initialization code in the ServiceStub.java file.
>>
>> It would be interesting to know if there is some flag to simply use
>> every generated class in the context or if the used fix is acceptable.
>>
>
> are you using xsd:anyType or xsd:any ? will you be able to send a simple
> sample file to
> show the error?

Hi Amila,

thanks for your reply.

We use xsd:any.

I have appended two schema files which have very "dumb" elements and
used in the wsdl. The problem can be observed after generating the necessary
code with wsdl2java -d jaxbri and running the main() in the Driver class.

 	Caused by: javax.xml.bind.MarshalException
 	- with linked exception:
 	[javax.xml.bind.JAXBException: class namespace2.ElementFromSchema2 nor
 	any of its super class is known to this context.]

Modifying the JAXBContext initialization around line 430 in the generated
ServiceStub.java file as described above fixes the problem.
Namely adding namespace2.ElementFromSchema2.class to the newInstance()
call.

Hope the problem is clearer with this example...

Thanks,
Arne

Re: wsdl2java using jaxb and multiple schemes, Marshaling Exeption

Posted by Amila Suriarachchi <am...@gmail.com>.
On Wed, Apr 7, 2010 at 9:51 PM, Arne Welzel <ar...@googlemail.com>wrote:

> Hi all,
>
> i have a question regarding wsdl2java using JAXBRI as databinding
> option. The wsdl is referencing two "somewhat" independent schema files.
>
> I'm describing the problem in general as I'm not allowed to publish the
> used files. If needed I can construct an example which should show the
> observed problem.
>
> We have the following situation:
>  - wsdl containing message definitions which reference elements
>   from our first schema.
>
>  - One of the types given in the first schema uses xsd:Any.
>   This is where the second schema file comes into play.
>
>  - Every element defined in the second schema may be put where xsd:Any
>   is used. (This is the dependency between those schemas). Besides
>   the elements given in the second schema everything else might be
>   used, those are some "known" elements.
>
> When running wsdl2java, classes for the elements in the second schema
> are generated. However using those classes and putting them into the
> xsd:Any position ( obj.getAny().add(objectofgeneratedclass) ) leads to a
> MarshalException / JAXBException saying "<class>  nor any of its super
> class is known to this context".
>
> I was able to solve this by adding the generated classes to the context
> initialization code in the ServiceStub.java file.
>
> It would be interesting to know if there is some flag to simply use
> every generated class in the context or if the used fix is acceptable.
>

are you using xsd:anyType or xsd:any ? will you be able to send a simple
sample file to
show the error?

thanks,
Amila.

>
> Any further comments are welcome.
>
> As mentioned above, if the problem is not clear from the given
> description I can try to construct an example and post it.
>
> --
> Arne
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
> For additional commands, e-mail: java-user-help@axis.apache.org
>
>


-- 
Amila Suriarachchi
WSO2 Inc.
blog: http://amilachinthaka.blogspot.com/