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 "Moore, Don H" <DH...@midamerican.com> on 2006/11/09 16:26:37 UTC

Axis2 unexpected subelement error

I have an issue with generated Java code using wsdl2Java and Axis2 1.0.
I've also tried using Axis2 1.1, Nov 2 2006 build, and have the same
problem. From posts I've found in the archives, I see this has been
reported a few times before, but I haven't found a solution.
 
Essentially, if additional fields get added to the data which were not
in the wsdl when the java files were generated with Axis2, then the code
blows up with the java.lang.RuntimeException: Unexpected subelement
error. Obviously, I can regenerate the java code using a new wsdl. But,
as long as those additional fields are not needed in my application,
then I really shouldn't have to be continuously regenerating the java
code. Shouldn't the additional fields just be ignored by the parser?

Re: Axis2 unexpected subelement error

Posted by Davanum Srinivas <da...@gmail.com>.
Because it finds something that should not be there according to the
schema. Unless you originally had a schema that allowed a bag of any
elements, codegen will try to do the right thing. in this case, throw
an error that the xml you get is not according to the schema you
specified.

-- dims

On 11/9/06, Moore, Don H <DH...@midamerican.com> wrote:
> The elements are in order.
>
> Let me explain the problem a little more clearly. I generated code using
> a wsdl that does not include the field cdCustType because that field was
> not in the data.  The data now includes that field, but my application
> does not need it and there is nothing in the generated code about this
> field. The generated code throws the error when the parser comes to
> cdCustType.
>
> -----Original Message-----
> From: Davanum Srinivas [mailto:davanum@gmail.com]
> Sent: Thursday, November 09, 2006 10:48 AM
> To: axis-user@ws.apache.org
> Subject: Re: Axis2 unexpected subelement error
>
> Moore,
>
> It depends on the schema. *IF* your schema (in your wsdl) says, they are
> needed only then we throw an exception. We also throw an exception if
> the schema specifies a certain order and the runtime soap message does
> not have the same order.
>
> -- dims
>
> On 11/9/06, Moore, Don H <DH...@midamerican.com> wrote:
> >
> >
> > I have an issue with generated Java code using wsdl2Java and Axis2
> > 1.0. I've also tried using Axis2 1.1, Nov 2 2006 build, and have the
> same problem.
> > From posts I've found in the archives, I see this has been reported a
> > few times before, but I haven't found a solution.
> >
> > Essentially, if additional fields get added to the data which were not
>
> > in the wsdl when the java files were generated with Axis2, then the
> > code blows up with the java.lang.RuntimeException: Unexpected
> subelement error.
> > Obviously, I can regenerate the java code using a new wsdl. But, as
> > long as those additional fields are not needed in my application, then
>
> > I really shouldn't have to be continuously regenerating the java code.
>
> > Shouldn't the additional fields just be ignored by the parser?
>
>
> --
> Davanum Srinivas : http://www.wso2.net (Oxygen for Web Service
> Developers)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>


-- 
Davanum Srinivas : http://www.wso2.net (Oxygen for Web Service Developers)

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


Re: Axis2 unexpected subelement error

Posted by Dennis Sosnoski <dm...@sosnoski.com>.
Most XML processors will balk at elements that aren't present in the 
schema definition. The exceptions are older SOAP frameworks (including 
the original flavor of Axis, I think) and some newer frameworks that 
have decided to basically degrade schemas (JAX-WS/JAXB does this by 
default).

With JiBX data binding you can use a "flexible" unmarshalling flag to 
say that unknown elements within a particular grouping should be 
ignored. See 
http://jibx.sourceforge.net/tutorial/binding-extras.html#mixing for 
details on this. This *does* seem to be a fairly common requirement for 
certain business areas (I know several major users of JiBX in the travel 
industry who rely on this, for instance).

  - Dennis

Dennis M. Sosnoski
SOA, Web Services, and XML
Training and Consulting
http://www.sosnoski.com - http://www.sosnoski.co.nz
Seattle, WA +1-425-296-6194 - Wellington, NZ +64-4-298-6117



Moore, Don H wrote:
> The elements are in order.
>
> Let me explain the problem a little more clearly. I generated code using
> a wsdl that does not include the field cdCustType because that field was
> not in the data.  The data now includes that field, but my application
> does not need it and there is nothing in the generated code about this
> field. The generated code throws the error when the parser comes to
> cdCustType.
>
> -----Original Message-----
> From: Davanum Srinivas [mailto:davanum@gmail.com] 
> Sent: Thursday, November 09, 2006 10:48 AM
> To: axis-user@ws.apache.org
> Subject: Re: Axis2 unexpected subelement error
>
> Moore,
>
> It depends on the schema. *IF* your schema (in your wsdl) says, they are
> needed only then we throw an exception. We also throw an exception if
> the schema specifies a certain order and the runtime soap message does
> not have the same order.
>
> -- dims
>
> On 11/9/06, Moore, Don H <DH...@midamerican.com> wrote:
>   
>> I have an issue with generated Java code using wsdl2Java and Axis2 
>> 1.0. I've also tried using Axis2 1.1, Nov 2 2006 build, and have the
>>     
> same problem.
>   
>> From posts I've found in the archives, I see this has been reported a 
>> few times before, but I haven't found a solution.
>>
>> Essentially, if additional fields get added to the data which were not
>>     
>
>   
>> in the wsdl when the java files were generated with Axis2, then the 
>> code blows up with the java.lang.RuntimeException: Unexpected
>>     
> subelement error.
>   
>> Obviously, I can regenerate the java code using a new wsdl. But, as 
>> long as those additional fields are not needed in my application, then
>>     
>
>   
>> I really shouldn't have to be continuously regenerating the java code.
>>     
>
>   
>> Shouldn't the additional fields just be ignored by the parser?
>>     
>
>
> --
> Davanum Srinivas : http://www.wso2.net (Oxygen for Web Service
> Developers)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
>   

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


RE: Axis2 unexpected subelement error

Posted by "Moore, Don H" <DH...@midamerican.com>.
The elements are in order.

Let me explain the problem a little more clearly. I generated code using
a wsdl that does not include the field cdCustType because that field was
not in the data.  The data now includes that field, but my application
does not need it and there is nothing in the generated code about this
field. The generated code throws the error when the parser comes to
cdCustType.

-----Original Message-----
From: Davanum Srinivas [mailto:davanum@gmail.com] 
Sent: Thursday, November 09, 2006 10:48 AM
To: axis-user@ws.apache.org
Subject: Re: Axis2 unexpected subelement error

Moore,

It depends on the schema. *IF* your schema (in your wsdl) says, they are
needed only then we throw an exception. We also throw an exception if
the schema specifies a certain order and the runtime soap message does
not have the same order.

-- dims

On 11/9/06, Moore, Don H <DH...@midamerican.com> wrote:
>
>
> I have an issue with generated Java code using wsdl2Java and Axis2 
> 1.0. I've also tried using Axis2 1.1, Nov 2 2006 build, and have the
same problem.
> From posts I've found in the archives, I see this has been reported a 
> few times before, but I haven't found a solution.
>
> Essentially, if additional fields get added to the data which were not

> in the wsdl when the java files were generated with Axis2, then the 
> code blows up with the java.lang.RuntimeException: Unexpected
subelement error.
> Obviously, I can regenerate the java code using a new wsdl. But, as 
> long as those additional fields are not needed in my application, then

> I really shouldn't have to be continuously regenerating the java code.

> Shouldn't the additional fields just be ignored by the parser?


--
Davanum Srinivas : http://www.wso2.net (Oxygen for Web Service
Developers)

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

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


Re: Axis2 unexpected subelement error

Posted by Davanum Srinivas <da...@gmail.com>.
Moore,

It depends on the schema. *IF* your schema (in your wsdl) says, they
are needed only then we throw an exception. We also throw an exception
if the schema specifies a certain order and the runtime soap message
does not have the same order.

-- dims

On 11/9/06, Moore, Don H <DH...@midamerican.com> wrote:
>
>
> I have an issue with generated Java code using wsdl2Java and Axis2 1.0. I've
> also tried using Axis2 1.1, Nov 2 2006 build, and have the same problem.
> From posts I've found in the archives, I see this has been reported a few
> times before, but I haven't found a solution.
>
> Essentially, if additional fields get added to the data which were not in
> the wsdl when the java files were generated with Axis2, then the code blows
> up with the java.lang.RuntimeException: Unexpected subelement error.
> Obviously, I can regenerate the java code using a new wsdl. But, as long as
> those additional fields are not needed in my application, then I really
> shouldn't have to be continuously regenerating the java code. Shouldn't the
> additional fields just be ignored by the parser?


-- 
Davanum Srinivas : http://www.wso2.net (Oxygen for Web Service Developers)

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


Re: Axis2 unexpected subelement error

Posted by sridhar vudutha <sr...@gmail.com>.
Moore,
      Check if all the XML elements are in order (according to the schema
definition) and also check if all the required elements are there.
      I got this error and got rid of it with the above corrections.

Hope this helps,
Sridhar.


On 11/9/06, Moore, Don H <DH...@midamerican.com> wrote:
>
>  I have an issue with generated Java code using wsdl2Java and Axis2 1.0.
> I've also tried using Axis2 1.1, Nov 2 2006 build, and have the same
> problem. From posts I've found in the archives, I see this has been reported
> a few times before, but I haven't found a solution.
>
> Essentially, if additional fields get added to the data which were not in
> the wsdl when the java files were generated with Axis2, then the code blows
> up with the *java.lang.RuntimeException*: Unexpected subelement error.
> Obviously, I can regenerate the java code using a new wsdl. But, as long as
> those additional fields are not needed in my application, then I really
> shouldn't have to be continuously regenerating the java code. Shouldn't the
> additional fields just be ignored by the parser?
>