[ 
http://issues.apache.org/jira/browse/AXIS2-632?page=comments#action_12377304 ] 

Chuck Williams commented on AXIS2-632:
--------------------------------------

Any complex type can be extended.  According to the XML Schema specification, 
all complex types except for the root ur type are extensions or restrictions of 
some other type (just like in Java all types extend Object).  Generally base 
types will not have any kind of <any> declaration.  It is the subtype that has 
the additional fields.  XML allows use of a subtype wherever the supertype is 
required (again like Java and other OO systems).

The only issue in supporting xsi:type is arranging for runtime information 
about subtypes.  It seems to me the potentially tricky thing here has to do 
with class loaders, since we cannot in general know about the existence of a 
subtype if its class has not been loaded.  A very simple solution arises if 
there is a deterministic algorithm to find the subclass name from the QName 
argument to xsi:type, which in general there should be.  Then the parser can 
identify the subclass parser directly from the value of xsi:type and simply 
dispatch to it.  The generated code can check for the xsi:type attribute as its 
first step in attribute parsing -- I think that resolves all remaining issues.


> get errors trying to parse valid response
> -----------------------------------------
>
>          Key: AXIS2-632
>          URL: http://issues.apache.org/jira/browse/AXIS2-632
>      Project: Apache Axis 2.0 (Axis2)
>         Type: Bug

>   Components: databinding
>  Environment: Axis2.0 RC4, JDK 1.5.06, WinXP
>     Reporter: Simon Fell
>  Attachments: WhiteSpaceAndExtensionTypes.zip
>
> A valid response from the query call (wsdl is the enterprise wsdl that's now 
> part of the tests) fails to be de-serialized with an error.
> Exception in thread "main" java.lang.RuntimeException: 
> java.lang.RuntimeException: Unexpected subelement Name
>       at 
> org.apache.axis2.SforceServiceStub.fromOM(SforceServiceStub.java:59718)
>       at org.apache.axis2.SforceServiceStub.query(SforceServiceStub.java:2545)
>       at client.main(client.java:19)
> Caused by: java.lang.RuntimeException: Unexpected subelement Name
>       at 
> org.apache.axis2.SforceServiceStub$QueryResult$Factory.parse(SforceServiceStub.java:57735)
>       at 
> org.apache.axis2.SforceServiceStub$QueryResponse$Factory.parse(SforceServiceStub.java:20706)
>       at 
> org.apache.axis2.SforceServiceStub.fromOM(SforceServiceStub.java:59594)
>       ... 2 more
> Here's the response msg it fails to deserialize
> <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope 
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"; 
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
> xmlns="urn:enterprise.soap.sforce.com" 
> xmlns:sf="urn:sobject.enterprise.soap.sforce.com"><soapenv:Body><queryResponse><result><done>true</done><queryLocator
>  xsi:nil="true"/><records 
> xsi:type="sf:Account"><sf:Id>0013000000Bnr1qAAB</sf:Id><sf:AccountNumber>axis2Test</sf:AccountNumber><sf:Name>New
>  Account 2</sf:Name></records><records 
> xsi:type="sf:Account"><sf:Id>0013000000BnspUAAR</sf:Id><sf:AccountNumber>axis2Test</sf:AccountNumber><sf:Name>New
>  Account 
> 1</sf:Name></records><size>2</size></result></queryResponse></soapenv:Body></soapenv:Envelope>
> the client stub was generated with WSDL2Java -s -u -uri enterprise.wsdl
> The test code is
>               SforceServiceStub stub = new SforceServiceStub();
>               SforceServiceStub.Login l = new SforceServiceStub.Login();
>               l.setUsername("*username*");
>               l.setPassword("*password*");
>               SforceServiceStub.LoginResponse lr = stub.login(l);
>               
>               SforceServiceStub.SessionHeader sh = new 
> SforceServiceStub.SessionHeader();
>               sh.setSessionId(lr.getResult().getSessionId());
>               stub = new SforceServiceStub(lr.getResult().getServerUrl());
>               
>               SforceServiceStub.Query q = new SforceServiceStub.Query();
>               q.setQueryString("select id, name, AccountNumber from Account 
> where AccountNumber='axis2Test'");
>               SforceServiceStub.QueryResponse qr = stub.query(q, sh, null);
>               
>               System.out.println("query returned " + qr.getResult().getSize() 
> + " rows");
>               
>               for(SforceServiceStub.SObject o : qr.getResult().getRecords()) {
>                       SforceServiceStub.Account a = 
> (SforceServiceStub.Account)o;
>                       System.out.println(a.getId() + " " + a.getName() + " " 
> + a.getAccountNumber());
>               }
> Also the generated stub has getId() returning an OMElement, and not a string.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to