Hello everybody,
i don't know if my previous email has been sent correctly, since i have some issues with my internet connection.
So if it has already been sent, i'm sorry for spamming you.
If not, here is the problem i have, and i hope you will be able to help me.

I have two classes, named Category and CategoryInfo. The Category one has an array of CategoryInfo in its attributes.

public class Category
{
    private int Id = 0;
    private String name;
    private CategoryInfo[] data;
    private int shared = 0;
    private int userid = 0;
   // methods here
}

public class CategoryInfo
{
    private int ownerId=0;
    private String name;
    private String type;
    private int userid=0;
   // methods here
}

One of my webservice will add the content of a Category object in the database. Its name is SqlGenerator, and i call the insert method :

public Category insert(Category obj, String str) throws Exception, InternalException
    {
        try
        {
            if (SqlMisc.checkUserIsConnect(SqlMisc.decode(str)) == 0)
                throw new Exception("Todo : add here an exception saying that the user is not connected");
            if (obj.getData() == null )
                throw new Exception("Todo : DATA = "">            if (obj.getData().length == 0 )
                throw new Exception("Todo : LENGTH = 0");
            CategoryGenerator cat = new CategoryGenerator();
            cat.setCategory(obj);
            obj.setId(cat.generateCategory());
            cat.generateCategoryInfo();
            DbConnection.getInstance ().getConnection().commit();
            return obj;
        }
        catch (InternalException e)
        {
            DbConnection.getInstance().getConnection().rollback();
            throw new InternalException( TablesExceptions.getInstance().getUserMessage(e.getMessage()));
        }
    }

I call this webservice this way :
public static Category testAddCategory() throws Exception
    {
        Category cat = new Category();
        CategoryInfo catInfo = new CategoryInfo();
        CategoryInfo catInfo2 = new CategoryInfo();
              
        cat.setName("BBBBBBB");
        cat.setShared(0);
        cat.setUserid (1);
        catInfo.setName("NAME1");
        catInfo.setType("Text");  
        catInfo2.setName("NAME2");
        catInfo2.setType("Doc");
        cat.setData(catInfo);
        cat.setData(catInfo2);
        try
           {
             String endpoint = "http://localhost:8080/axis/services/SqlGenerator";
             
            Service  service = new Service();
            Call     call    = (Call) service.createCall();
            QName    qn = new QName("ns:Category", "Category");
            call.registerTypeMapping(objects.Category.class, qn,
                    new org.apache.axis.encoding.ser.BeanSerializerFactory(objects.Category.class, qn),      
                    new org.apache.axis.encoding.ser.BeanDeserializerFactory (objects.Category.class, qn));
            QName    qn3 = new QName("ns:CategoryInfo", "CategoryInfo");
            call.registerTypeMapping(objects.CategoryInfo.class, qn3,
                    new org.apache.axis.encoding.ser.BeanSerializerFactory(objects.CategoryInfo.class, qn3),      
                    new org.apache.axis.encoding.ser.BeanDeserializerFactory(objects.CategoryInfo.class, qn3));
            QName    qn2 = new QName("ns:ArrayOfCategoryInfo", "CategoryInfo[]");
            call.registerTypeMapping(objects.CategoryInfo[].class, qn2,
                    new org.apache.axis.encoding.ser.ArraySerializerFactory(objects.CategoryInfo[].class, qn2),      
                    new org.apache.axis.encoding.ser.ArrayDeserializerFactory(qn2));
            call.setTargetEndpointAddress( new java.net.URL(endpoint) );
            call.setOperationName(new QName(" http://webservices.sql.generator.SqlGenerator", "insert"));
            call.addParameter("arg1", qn , ParameterMode.IN);
            call.addParameter("arg2", XMLType.XSD_STRING , ParameterMode.IN);
            call.setReturnType( qn);
            cat = (Category)(call.invoke( new Object[] {cat, encode("1:1:yahoo")} ));         
            System.out.println("Result for TestAddCategory : " + cat.toString() + "'");
            return cat;
          }
           catch (Exception e) {
            System.err.println("error : ");
            e.printStackTrace();
          }
        return null;
    }

Here is my wsd file :
<deployment
    xmlns="http://xml.apache.org/axis/wsdd/"
    xmlns:java=" http://xml.apache.org/axis/wsdd/providers/java">

  <!-- Services from SqlGeneratorService WSDL service -->

  <service name="SqlGenerator" provider="java:RPC" style="rpc" use="encoded">
       <parameter name="className" value="webservices.sql.generator.SqlGenerator"/>
        <parameter name="allowedMethods" value="*"/>
      
      
    <beanMapping qname="ns:Directory" xmlns:ns="http://objects" languageSpecificType="java:objects.Directory"/>
    <beanMapping qname="ns:Category" xmlns:ns=" http://objects" languageSpecificType="java:objects.Category"/>
    <beanMapping qname="ns:CategoryInfo" xmlns:ns="http://objects " languageSpecificType="java:objects.CategoryInfo"/>
    <beanMapping qname="ns:ArrayOfCategoryInfo" xmlns:ns="http://objects" languageSpecificType="java: objects.CategoryInfo[]"/>
  
      <typeMapping
        xmlns:ns="http://exceptions"
        qname="ns:InternalException"
        type="java: exceptions.InternalException"
        serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
        deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
        encodingStyle=" http://schemas.xmlsoap.org/soap/encoding/"
      />
      <typeMapping
        xmlns:ns="http://objects"
        qname="ns:Directory"
        type="java:objects.Directory"
        serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
        deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory "
        encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      />
      <typeMapping
        xmlns:ns=" http://objects"
        qname="ns:CategoryInfo"
        type="java:objects.CategoryInfo"
        serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
        deserializer=" org.apache.axis.encoding.ser.BeanDeserializerFactory"
        encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      />
      <typeMapping
        xmlns:ns="http://objects"
        qname="ns:Category"
        type="java:objects.Category"
        serializer="org.apache.axis.encoding.ser.BeanSerializerFactory "
        deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
        encodingStyle="http://schemas.xmlsoap.org/soap/encoding/ "
      />
      <arrayMapping
        xmlns:ns="http://objects"
        qname="ns:ArrayOfCategoryInfo"
        type="java:objects.CategoryInfo []"
        innerType="cmp-ns:CategoryInfo" xmlns:cmp-ns="http://objects"
        serializer="org.apache.axis.encoding.ser.ArraySerializerFactory"
        deserializer=" org.apache.axis.encoding.ser.ArrayDeserializerFactory"
        encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      />
  </service>
</deployment>

But each time i call this webservice, i have the same error (because my data[] field has a 0 length).
AxisFault
 faultCode: { http://schemas.xmlsoap.org/soap/envelope/}Server.userException
 faultSubcode:
 faultString: java.lang.Exception: Todo : LENGTH = 0
 faultActor:
 faultNode:
 faultDetail:

But, in my soap message, i see that the array has been successfully deserialized :
<?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">
      <soapenv:Body>
         <ns1:insert soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1=" http://webservices.sql.generator.SqlGenerator">
            <arg1 href="">            <arg2 xsi:type="xsd:string">:&#xB2;Wd&#xB6;&#xD2;q&#xE7;&#x95;</arg2>
         </ns1:insert>
         <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/ " xsi:type="ns2:Category" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="ns:Category">
            <data soapenc:arrayType="ns3:CategoryInfo[2]" xsi:type="soapenc:Array" xmlns:ns3="ns:CategoryInfo">
               <data href="">               <data href="">            </data>
            <id href="">            <name xsi:type="soapenc:string">BBBBBBB</name>
            <shared href="">            <userid href="">         </multiRef>
         <multiRef id="id5" soapenc:root="0" soapenv:encodingStyle=" http://schemas.xmlsoap.org/soap/encoding/" xsi:type="xsd:int" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/ ">1</multiRef>
         <multiRef id="id4" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/ " xsi:type="xsd:int" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">0</multiRef>
         <multiRef id="id2" soapenc:root="0" soapenv:encodingStyle=" http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns4:CategoryInfo" xmlns:ns4="ns:CategoryInfo" xmlns:soapenc=" http://schemas.xmlsoap.org/soap/encoding/">
            <name xsi:type="soapenc:string">NAME2</name>
            <ownerId href="">            <type xsi:type="soapenc:string">Doc</type>
            <userid href="">         </multiRef>
         <multiRef id="id1" soapenc:root="0" soapenv:encodingStyle=" http://schemas.xmlsoap.org/soap/encoding/" xsi:type="ns5:CategoryInfo" xmlns:ns5="ns:CategoryInfo" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/ ">
            <name xsi:type="soapenc:string">NAME1</name>
            <ownerId href="">            <type xsi:type="soapenc:string">Text</type>
            <userid href="">         </multiRef>
         <multiRef id="id3" soapenc:root="0" soapenv:encodingStyle=" http://schemas.xmlsoap.org/soap/encoding/" xsi:type="xsd:int" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">0</multiRef>
         <multiRef id="id9" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="xsd:int" xmlns:soapenc=" http://schemas.xmlsoap.org/soap/encoding/">0</multiRef>
         <multiRef id="id8" soapenc:root="0" soapenv:encodingStyle=" http://schemas.xmlsoap.org/soap/encoding/" xsi:type="xsd:int" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/ ">0</multiRef>
         <multiRef id="id6" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/ " xsi:type="xsd:int" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">0</multiRef>
         <multiRef id="id7" soapenc:root="0" soapenv:encodingStyle=" http://schemas.xmlsoap.org/soap/encoding/" xsi:type="xsd:int" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/ ">0</multiRef>
      </soapenv:Body>
   </soapenv:Envelope>

So, i dont really understant why this array is empty !
I did the same test only sending arrays of CategoryInfo, and it worked well. So i guess my problem is coming from the de/serialization of the Category class.
I've been trying to solve this problems for days now, i don't know what to do. The worst point is that all my future webservices will use arrays of classes.
Does anyone have an idea ?

Thanks in advance!






Reply via email to