axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ellecer Valencia <elle...@gmail.com>
Subject Re: "ADBException: Unexpected subelement " - error caused by space after element name in schema
Date Mon, 09 Nov 2009 04:50:55 GMT
Thanks for the suggestion Dennis. I have also used it to generate
client code via CXF (which defaults to JAXB), and didn't fail on
generation of code as well.  Haven't looked at xmlbeans or jibx yet.

I also got errors  about "unexpected subelement" when calling the web
service, but it was for completely different types/elements, not on
the "partnerMessageOption" field which had the embedded space.

I'll see if we can come up with some scripts to verify element names
for these stray spaces.

Ellecer

On Mon, Nov 9, 2009 at 3:17 PM, Dennis Sosnoski <dms@sosnoski.com> wrote:
> Hi Ellecer,
>
> I'd say this is an error in your schema definition and should be reported as
> such by the schema processing. Schema says the value of the name attribute
> should be of type NCName, which only allows name characters in the value.
>
> Have you tried this schema with any other schema tools? It'd be interesting
> to see if they treated the space as an error, or just ignore it.
>
>  - Dennis
>
> --
> Dennis M. Sosnoski
> Java XML and Web Services
> Axis2 Training and Consulting
> http://www.sosnoski.com - http://www.sosnoski.co.nz
> Seattle, WA +1-425-939-0576 - Wellington, NZ +64-4-298-6117
>
>
> Ellecer Valencia wrote:
>>
>> Hi,
>>
>> What's wrong with this schema fragment?
>>
>>        <element name="authorizePurchaseResponse">
>>                <complexType>
>>                        <sequence>
>>                                <element name="purchaseId" type="string"
>> maxOccurs="1"
>>                                        minOccurs="1"></element>
>>                                <element name="processedDate"
>> type="dateTime" maxOccurs="1"
>>                                        minOccurs="1"></element>
>>                                <element name="statusCode" type="string"
>> maxOccurs="1"
>>                                        minOccurs="1"></element>
>>                                <element name="paidAmount" type="decimal"
>> maxOccurs="1"
>>                                        minOccurs="0"></element>
>>                                <element name="errorShortCode"
>> type="string" maxOccurs="1"
>>                                        minOccurs="1"></element>
>>                                <element name="customerMessage"
>> type="string" maxOccurs="1"
>>                                        minOccurs="0"></element>
>>                                <element name="partnerMessageOption
"
>> type="boolean"
>>                                        maxOccurs="1"
>> minOccurs="0"></element>
>>                        </sequence>
>>                </complexType>
>>        </element>
>>
>>
>> I obviously wasn't looking hard enough, since to me there was
>> *nothing* wrong with it until the service I was writing actually tried
>> to use it in an operation. Then Axis2 returned this error:
>>
>>
>> org.apache.axis2.AxisFault: org.apache.axis2.databinding.ADBException:
>> Unexpected subelement partnerMessageOption
>>   at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
>>   at ChargingServiceStub.fromOM(ChargingServiceStub.java:847)
>>   at ChargingServiceStub.authorizePurchase(ChargingServiceStub.java:201)
>>   at ChargingClient.callService(ChargingClient.java:86)
>>   at GeneralClient.main(GeneralClient.java:76)
>> Caused by: java.lang.Exception:
>> org.apache.axis2.databinding.ADBException: Unexpected subelement
>> partnerMessageOption
>>   at
>> AuthorizePurchaseResponse$Factory.parse(AuthorizePurchaseResponse.java:1056)
>>   at ChargingServiceStub.fromOM(NDPChargingServiceStub.java:827)
>>   ...3 more
>> Caused by: org.apache.axis2.databinding.ADBException: Unexpected
>> subelement partnerMessageOption
>>
>>
>> Now I looked at the schema again and saw that there was an extra space
>> in the name  "partnerMessageOption ".
>>
>> Removing this space made the error go away.
>>
>> Now what I'm wondering is: are spaces at the end of element names
>> valid in XSD schema?
>>
>> If it's not, then shouldn't the error be detected and an exception
>> thrown at the point of code generation and not at runtime?
>>
>> Hopefully this helps someone who's experienced the same error and is
>> just as puzzled by the "Unexpected subelement" message.
>>
>>
>> Ellecer
>>
>>
>

Mime
View raw message