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 "Swaminathan, Bhaskar" <Bh...@lehman.com> on 2004/06/22 17:25:37 UTC

Issue with user type array deserialization

Folks

I am running into an issue with user-defined types in doc/literal(at the
bottom are
the java client using generated stub and the hand-coded WSDL):

SEVERE: Exception:
org.xml.sax.SAXException: Invalid element in
clients.doclit.generated.UserObject
Array - firstName
        at
org.apache.axis.encoding.ser.BeanDeserializer.onStartChild(BeanDeseri
alizer.java:227)
        at
org.apache.axis.encoding.DeserializationContextImpl.startElement(Dese
rializationContextImpl.java:1008)
        at
org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.ja
va:159)
        at
org.apache.axis.message.MessageElement.publishToHandler(MessageElemen
t.java:1056)
        at
org.apache.axis.message.RPCElement.deserialize(RPCElement.java:196)
        at org.apache.axis.message.RPCElement.getParams(RPCElement.java:310)
        at org.apache.axis.client.Call.invoke(Call.java:2405)
        at org.apache.axis.client.Call.invoke(Call.java:2304)
        at org.apache.axis.client.Call.invoke(Call.java:1765)
        at
clients.doclit.generated.ProductUsersPortSoapBindingStub.getAllUsers(
ProductUsersPortSoapBindingStub.java:150)
        at
clients.doclit.ProductUsersStubClient.main(ProductUsersStubClient.jav
a:24)
AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
<http://schemas.xmlsoap.org/soap/envelope/}Server.userException> 
 faultSubcode:
 faultString: org.xml.sax.SAXException: Invalid element in
clients.doclit.genera
ted.UserObjectArray - firstName
 faultActor:
 faultNode:
 faultDetail:
        {http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXException
<http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXException> : Invali
d element in clients.doclit.generated.UserObjectArray - firstName
        at
org.apache.axis.encoding.ser.BeanDeserializer.onStartChild(BeanDeseri
alizer.java:227)
        at
org.apache.axis.encoding.DeserializationContextImpl.startElement(Dese
rializationContextImpl.java:1008)
        at
org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.ja
va:159)
        at
org.apache.axis.message.MessageElement.publishToHandler(MessageElemen
t.java:1056)
        at
org.apache.axis.message.RPCElement.deserialize(RPCElement.java:196)
        at org.apache.axis.message.RPCElement.getParams(RPCElement.java:310)
        at org.apache.axis.client.Call.invoke(Call.java:2405)
        at org.apache.axis.client.Call.invoke(Call.java:2304)
        at org.apache.axis.client.Call.invoke(Call.java:1765)
        at
clients.doclit.generated.ProductUsersPortSoapBindingStub.getAllUsers(
ProductUsersPortSoapBindingStub.java:150)
        at
clients.doclit.ProductUsersStubClient.main(ProductUsersStubClient.jav
a:24)

        {http://xml.apache.org/axis/}hostname:PLT-Bhaskar
<http://xml.apache.org/axis/}hostname:PLT-Bhaskar> 

org.xml.sax.SAXException: Invalid element in
clients.doclit.generated.UserObject
Array - firstName
        at org.apache.axis.AxisFault.makeFault(AxisFault.java:99)
        at org.apache.axis.client.Call.invoke(Call.java:2408)
        at org.apache.axis.client.Call.invoke(Call.java:2304)
        at org.apache.axis.client.Call.invoke(Call.java:1765)
        at
clients.doclit.generated.ProductUsersPortSoapBindingStub.getAllUsers(
ProductUsersPortSoapBindingStub.java:150)
        at
clients.doclit.ProductUsersStubClient.main(ProductUsersStubClient.jav
a:24)
Caused by: org.xml.sax.SAXException: Invalid element in
clients.doclit.generated
.UserObjectArray - firstName
        at
org.apache.axis.encoding.ser.BeanDeserializer.onStartChild(BeanDeseri
alizer.java:227)
        at
org.apache.axis.encoding.DeserializationContextImpl.startElement(Dese
rializationContextImpl.java:1008)
        at
org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.ja
va:159)
        at
org.apache.axis.message.MessageElement.publishToHandler(MessageElemen
t.java:1056)
        at
org.apache.axis.message.RPCElement.deserialize(RPCElement.java:196)
        at org.apache.axis.message.RPCElement.getParams(RPCElement.java:310)
        at org.apache.axis.client.Call.invoke(Call.java:2405)
        ... 4 more
        
-------------------------------

Here is the Java client:

import javax.xml.rpc.Service;
import javax.xml.rpc.Stub;

import clients.doclit.generated.*;

public class ProductUsersStubClient {
    // ----- Public Method(s) -----

    public static void main(String[] args) {
        try {
            ProductUsersPortType port = (ProductUsersPortType) getStub();

            UserObjectArray userArray = port.getAllUsers();
            
            User[] users = userArray.getUser();

            int count = 0;

            if (users != null) {
                count = users.length;
            }

            System.out.println("ProductUsersStubClient: Reported no. of
users: " + count);

            for (int i = 0; i < count; i++) {
                System.out.println("User: " + users[i].getLastName() + ", "
+ users[i].getFirstName());
            }
        }
        catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    // ----- Private Method(s) -----

    private static Stub getStub()
        throws Exception {
        Stub stub = null;

        Service service = new ProductUsersServiceLocator();

        stub = (Stub) service.getPort(ProductUsersPortType.class);

        return stub;
    }
}

-------------------------------

Here is the handcrafted WSDL:

<wsdl:definitions targetNamespace="http://ProductUsers"
                  xmlns:impl="http://ProductUsers"
                  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
                  xmlns:soapbind="http://schemas.xmlsoap.org/wsdl/soap/"
                  xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<wsdl:types>
    <xsd:schema elementFormDefault="qualified" xmlns="http://ProductUsers">
        <xsd:complexType name="User">
            <xsd:sequence>
                <xsd:element name="firstName" type="xsd:string"/>
                <xsd:element name="lastName" type="xsd:string"/>
            </xsd:sequence>
        </xsd:complexType>
        
        <xsd:complexType name="UserObjectArray">
            <xsd:sequence>
                <xsd:element name="User" type="impl:User" minOccurs="0"
maxOccurs="unbounded"/>
            </xsd:sequence>
        </xsd:complexType>
        
        <xsd:element name="getAllUsersReturn" type="impl:UserObjectArray"/>
    </xsd:schema>
</wsdl:types>

<wsdl:message name="getAllUsersRequest"/>

<wsdl:message name="getAllUsersResponse">
    <wsdl:part name="getAllUsersReturn" element="impl:getAllUsersReturn"/>
</wsdl:message>

<wsdl:portType name="ProductUsersPortType">
    <wsdl:operation name="getAllUsers">
        <wsdl:input name="getAllUsersRequest"
message="impl:getAllUsersRequest"/>
        <wsdl:output name="getAllUsersResponse"
message="impl:getAllUsersResponse"/>
    </wsdl:operation>
</wsdl:portType>

<wsdl:binding name="ProductUsersPortSoapBinding"
type="impl:ProductUsersPortType">
    <soapbind:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="getAllUsers">
        <soapbind:operation soapAction=""/>
        <wsdl:input name="getAllUsersRequest">
            <soapbind:body use="literal"/>
        </wsdl:input>
        <wsdl:output name="getAllUsersResponse">
            <soapbind:body use="literal"/>
        </wsdl:output>
    </wsdl:operation>
</wsdl:binding>

<wsdl:service name="ProductUsersService">
    <wsdl:port binding="impl:ProductUsersPortSoapBinding"
name="ProductUsersPort">
        <soapbind:address
location="http://localhost:9090/axis/services/ProductUsers"/>
    </wsdl:port>
</wsdl:service>

</wsdl:definitions>

-------------------------------

Here is the message on the wire:

HTTP/1.1 200 OK
Content-Type: text/xml;charset=utf-8
Date: Tue, 22 Jun 2004 14:29:15 GMT
Server: Apache-Coyote/1.1
Connection: close

<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">
<soapenv:Body>
    <getAllUsersReturn xmlns="">
        <firstName>a</firstName>
        <lastName>b</lastName>
    </getAllUsersReturn>
    <getAllUsersReturn>
        <firstName>c</firstName>
        <lastName>d</lastName>
    </getAllUsersReturn>
    <getAllUsersReturn>
        <firstName>e</firstName>
        <lastName>f</lastName>
    </getAllUsersReturn>
    <getAllUsersReturn>
        <firstName>g</firstName>
        <lastName>h</lastName>
    </getAllUsersReturn>
    <getAllUsersReturn>
        <firstName>i</firstName>
        <lastName>j</lastName>
    </getAllUsersReturn>
</soapenv:Body>
</soapenv:Envelope>



------------------------------------------------------------------------------
This message is intended only for the personal and confidential use of the
designated recipient(s) named above.  If you are not the intended recipient of
this message you are hereby notified that any review, dissemination,
distribution or copying of this message is strictly prohibited.  This
communication is for information purposes only and should not be regarded as
an offer to sell or as a solicitation of an offer to buy any financial
product, an official confirmation of any transaction, or as an official
statement of Lehman Brothers.  Email transmission cannot be guaranteed to be
secure or error-free.  Therefore, we do not represent that this information is
complete or accurate and it should not be relied upon as such.  All
information is subject to change without notice.