axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Boris Klug <bo...@klg.de>
Subject Re: anyType and til values/empty strings - exception thrown
Date Mon, 22 Jun 2009 18:57:35 GMT
Hi!

Its not my code, its the code generated by wsdl2java - so what can I do?

Am 22.06.2009 um 16:51 schrieb Andreas Veithen:

> Anyway, the code is wrong and should use getElementText instead of
> getText to make sure that it gives the expected result even if the
> underlying parser is not coalescing. This would also solve the problem
> with empty text (getElementText returns an empty string in that case)
> and I think that is what the generated code does. Note that your last
> comment implies that anyType handling uses totally different code than
> the processing of typed elements. This is really strange!
>
> Andreas
>
> On Mon, Jun 22, 2009 at 14:14, Boris Klug<boris@klg.de> wrote:
>> Hi!
>>
>> I created a wsdl which contains a attribute/value pair where the
>> value is definied as xsd:anyType:
>>
>> <xs:complexType name="ZAttributeValue">
>>  <xs:sequence>
>>    <xs:element name="name"                        type="xs:string" />
>>    <xs:element name="displayName" nillable="true" type="xs:string" />
>>    <xs:element name="value"       nillable="true"  
>> type="xs:anyType" />
>>    <xs:element name="className"   nillable="true" type="xs:string" />
>>  </xs:sequence>
>>  </xs:complexType>
>>
>> Now I used wsdl2java to create client and server code using adb  
>> data binding.
>>
>> When value is "" (=empty string), the client throws this exception:
>>
>> Exception in thread "main" org.apache.axis2.AxisFault: Current  
>> state END_ELEMENT is not among the statesCHARACTERS, COMMENT,  
>> CDATA, SPACE, ENTITY_REFERENCE, DTD valid for getText()
>>        at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
>>        at  
>> de 
>> .mypackage.ZederbasicServiceStub.fromOM(ZederbasicServiceStub.java: 
>> 8846)
>>        at  
>> de 
>> .mypackage 
>> .ZederbasicServiceStub.getZEDERObjects(ZederbasicServiceStub.java: 
>> 1028)
>>        at ZederBasicClientTest.main(ZederBasicClientTest.java:36)
>> Caused by: java.lang.IllegalStateException: Current state  
>> END_ELEMENT is not among the statesCHARACTERS, COMMENT, CDATA,  
>> SPACE, ENTITY_REFERENCE, DTD valid for getText()
>>        at  
>> com 
>> .sun 
>> .org 
>> .apache 
>> .xerces 
>> .internal.impl.XMLStreamReaderImpl.getText(XMLStreamReaderImpl.java: 
>> 1052)
>>        at  
>> org 
>> .apache.axiom.om.impl.llom.OMStAXWrapper.getText(OMStAXWrapper.java: 
>> 418)
>>        at  
>> org 
>> .apache 
>> .axis2 
>> .databinding 
>> .utils.ConverterUtil.getAnyTypeObject(ConverterUtil.java:1528)
>>        at de.debeka.repository.zws
>>
>> In this case, the soap message looks like this:
>>
>> <attributes xmlns="http://model.zws2.boq.debeka.gen/xsd">
>>  <name>HINWEIS</name>
>>  <displayName>Hinweis</displayName>
>>  <value xmlns:s45="http://www.w3.org/2001/XMLSchema-instance"  
>> xmlns:s46="http://www.w3.org/2001/XMLSchema" s45:type="s46:string">
>>  </value>
>>  <className>java.lang.String</className>
>> </attributes>
>>
>> When value is set to null, I get this exception:
>>
>> Exception in thread "main" org.apache.axis2.AxisFault:  
>> org.apache.axis2.databinding.ADBException: Unexpected subelement  
>> value
>>        at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
>>        at  
>> de 
>> .mypackage.ZederbasicServiceStub.fromOM(ZederbasicServiceStub.java: 
>> 8846)
>>        at  
>> de 
>> .mypackage 
>> .ZederbasicServiceStub.getZEDERObjects(ZederbasicServiceStub.java: 
>> 1028)
>>        at ZederBasicClientTest.main(ZederBasicClientTest.java:36)
>> Caused by: java.lang.Exception:  
>> org.apache.axis2.databinding.ADBException: Unexpected subelement  
>> value
>>        at de.mypackage.ZederbasicServiceStub$ZAttributeValue 
>> $Factory.parse(ZederbasicServiceStub.java:2583)
>>        at de.mypackage.ZederbasicServiceStub$ZDataObject 
>> $Factory.parse(ZederbasicServiceStub.java:7596)
>>        at de.mypackage.ZederbasicServiceStub$GetZEDERObjectsResponse 
>> $Factory.parse(ZederbasicServiceStub.java:4833)
>>        at  
>> de 
>> .mypackage.ZederbasicServiceStub.fromOM(ZederbasicServiceStub.java: 
>> 8833)
>>        ... 2 more
>> Caused by: org.apache.axis2.databinding.ADBException: Unexpected  
>> subelement value
>>        at de.mypackage.ZederbasicServiceStub$ZAttributeValue 
>> $Factory.parse(ZederbasicServiceStub.java:2569)
>>        ... 5 more
>>
>> The soap message is:
>>
>> <attributes xmlns="http://model.zws2.boq.debeka.gen/xsd">
>>  <name>KLASSE</name>
>>  <displayName xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
>> xsi:nil="1" />
>>  <value xmlns:s29="http://www.w3.org/2001/XMLSchema-instance"  
>> xmlns:s30="http://www.w3.org/2001/XMLSchema"  
>> s29:type="s30:string">C_Jobplan</value>
>>  <className>java.lang.Integer</className>
>> </attributes>
>>
>>
>> I tried Axis2 1.4.1 and the new 1.5 version. The whole problem with  
>> nil and
>> empty string values only exists with anyType, not if the element is  
>> declared
>> as string or something else.
>>
>> I really need anyType here.
>>
>> Thank you for your help in advance.
>>
>>
>> --
>> Boris Klug, Koblenz, boris@klg.de, Fax: 0261-1334249
>>

-- 
Boris Klug, boris@klg.de




Mime
View raw message