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 Leonardo Razuk Jorge Froede <le...@smartprice.com.br> on 2004/11/25 22:39:40 UTC

Problems serializing an array.

Hello everyone,

In a previous message, i said i was having a problem calling a method in
a web-service which takes a class with a nested array as argument. I
tried to solve the problem declaring the array as a typemepping in the
web-service.xml file, but now, instead of the 'SimpleDeserializer
encountered a child element...' fault message, i get the 'No
deserializer for {http://www.w3.org/2001/XMLSchema}anyType' one. I am
using Jboss321, axis 1.2RC2 at the client and generating the client
files with WSDL2Java. The problems seems to be really with the array
mapping, cause the webservice works fine for classes with no nested
arrays. The classes are Bundle (abstract superclass), BuyBundle and
BundleItem (the class in the nested array).

Any help would be fine.

The Bundle class:

public abstract class Bundle extends ValueObject {

	protected BundlePK primaryKey;
	
	protected BundleItem[] bundleItem;

	public Bundle() {
		super();
		primaryKey = new BundlePK();
	}

	public PrimaryKey getPrimaryKey() {
		return this.primaryKey;
	}
	
	public void setPrimaryKey(PrimaryKey pk) {
		this.primaryKey = (BundlePK)pk;
	}
	
	public long getCode() {
		return this.primaryKey.getCode();
	}

	public void setCode(long code) {
		this.primaryKey.setCode(code);
	}
	
	public BundleItem[] getBundleItem() {
		return bundleItem;
	}

	public void setBundleItem(BundleItem[] bundleItem) {
		this.bundleItem = bundleItem;
	}
}

The web-service.xml file (only the direct involved typemappings):

<deployment xmlns="http://xml.apache.org/axis/wsdd/" 
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">

   <service name="freecommerce_basicclasses" provider="java:RPC"
style="wrapped" use="literal">

     <typeMapping
        xmlns:ns="http://valueobject.webservice.eb.smartprice.com"
        qname="ns:Bundle"
        type="java:com.smartprice.eb.webservice.valueobject.Bundle"
        serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
       
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
        encodingStyle=""
      />
     <typeMapping
        xmlns:ns="http://valueobject.webservice.eb.smartprice.com"
        qname="ns:BundleItem"
        type="java:com.smartprice.eb.webservice.valueobject.BundleItem"
        serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
       
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
        encodingStyle=""
      />
     <typeMapping
        xmlns:ns="http://valueobject.webservice.eb.smartprice.com"
        qname="ns:ArrayOfBundleItem"
       
type="java:com.smartprice.eb.webservice.valueobject.BundleItem[]"
        serializer="org.apache.axis.encoding.ser.ArraySerializerFactory"
       
deserializer="org.apache.axis.encoding.ser.ArrayDeserializerFactory"
        encodingStyle=""
      />
     <typeMapping
        xmlns:ns="http://valueobject.webservice.eb.smartprice.com"
        qname="ns:BuyBundle"
        type="java:com.smartprice.eb.webservice.valueobject.BuyBundle"
        serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
       
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
        encodingStyle=""
      />
  </service>
</deployment>

The request SOAP message:

<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><createBuyBundle
xmlns="http://webservice.eb.smartprice.com">
    <user xmlns="">teste</user>
    <passwd xmlns="">teste</passwd>
    <callerCode xmlns="">4</callerCode>
    <buyBundle xmlns="">
      <primaryKey xsi:nil="true"/>
      <bundleItem>
        <primaryKey xsi:type="ns1:BundleItemPK"
xmlns:ns1="http://valueobject.webservice.eb.smartprice.com">
          <product>
            <primaryKey xsi:type="ns1:ProductPK">
              <code>3</code>
              <partnerName>teste</partnerName>
            </primaryKey>
          </product>
        </primaryKey>
        <saved>false</saved>
        <quantity>100</quantity>
      </bundleItem>
      <bundleItem>
        <primaryKey xsi:type="ns2:BundleItemPK"
xmlns:ns2="http://valueobject.webservice.eb.smartprice.com">
          <product>
            <primaryKey xsi:type="ns2:ProductPK">
              <code>4</code>
              <partnerName>teste</partnerName>
            </primaryKey>
          </product>
        </primaryKey>
        <saved>false</saved>
        <quantity>100</quantity>
      </bundleItem>
      <bundleItem>
        <primaryKey xsi:type="ns3:BundleItemPK"
xmlns:ns3="http://valueobject.webservice.eb.smartprice.com">
          <product>
            <primaryKey xsi:type="ns3:ProductPK">
              <code>5</code>
              <partnerName>teste</partnerName>
            </primaryKey>
          </product>
        </primaryKey>
        <saved>false</saved>
        <quantity>100</quantity>
      </bundleItem>
      <code>0</code>
      <buyer>
        <primaryKey xsi:type="ns4:AbstractUserPK"
xmlns:ns4="http://valueobject.webservice.eb.smartprice.com">
          <code>4</code>
          <partnerName>teste</partnerName>
        </primaryKey>
      </buyer>
    </buyBundle>
  </createBuyBundle></soapenv:Body>
</soapenv:Envelope>

The response SOAP Message: 

<?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://w	ww.w3.org/2001/XMLSchema-instance">
 <soapenv:Body>
  <soapenv:Fault>
   <faultcode>soapenv:Server.userException</faultcode>
   <faultstring>org.xml.sax.SAXException: No deserializer for
{http://www.w3.org/2001/XMLSchema}anyType</faultstring>
   <detail/>
  </soapenv:Fault>
 </soapenv:Body>
</soapenv:Envelope>

regards,

Leo