Hi,

If you use the array of uer defined complex types in your web service then
you will have to specify the typemapping for the complex type as well as
for array of the complex type.

The sample type mapping for using array of user defined types can be as
shoen below.

  <typeMapping
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";
qname="ns670:SOAPStruct"
serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
type="java:datainter.SOAPStruct" xmlns:ns670="http://soapinterop.org/xsd"/>
  <typeMapping
deserializer="org.apache.axis.encoding.ser.ArrayDeserializerFactory"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";
qname="ns671:ArrayOfSOAPStruct"
serializer="org.apache.axis.encoding.ser.ArraySerializerFactory"
type="java:datainter.SOAPStruct[]"
xmlns:ns671="http://soapinterop.org/xsd"/>


And ofcourse you will have to write the class which refresent the complex
type. Write the interface and implementation and deploy the service using
wsdd. I'm sure you know rest of the drill.

You do not have to write any custom serializer, unless you really want to.

hope this helps.

regards,
Shrikant Wagh
Optimyz Software, Inc.
"Making Software Robust"
Email: [EMAIL PROTECTED]
Web: www.optimyz.com

For more information about WebServiceTester product visit www.optimyz.com.


Original Message:
-----------------
From: Cobble, Tim [EMAIL PROTECTED]
Date: Wed, 01 Oct 2003 14:23:06 -0400
To: [EMAIL PROTECTED]
Subject: ComplexType Array


All,

I feel I am asking a repeated question so I apologize.
How do I return an array of my custom complex type? I always get a null
pointer exception.
I have read that I need to write my own custom serializer/deserializer
class.  Is this the case?  I can not find an example anywhere on the
web.  Can anyone provide just the simplest of examples?

If this is not the case and I am just missing something small, below is
the test code I have been using with the Deployment Descriptor.

Thanks for your help!!!!

//-------------C O M P L E X   T Y P E
--------------------------------------------------------
//
public class TestArray
{
  public TestArray(){}
  public TestArray(int inInt1, int inInt2)
  {
    attr1 = inInt1;
    attr2 = inInt2;
  }

  protected int attr1;
  protected int attr2;

  public void setAttr1(int inInt){attr1 = inInt;}
  public void setAttr2(int inInt){attr2 = inInt;}

  public int getAttr1(){return attr1;}
  public int getAttr2(){return attr2;}
}

//---------------W E B    S E R V I C
E------------------------------------------------------
//
import java.util.*;
public class WebS1

{
  public TestArray [] MyWS()
  {
    TestArray[] ta = new TestArray[10];
    
    for (int i =0; i < 10; i++)
    {
      ta[i] = new TestArray(i,i);
    }
    
    return ta;
  }
}

//------------  D D
-------------------------------------------------------------------
//
<deployment xmlns="http://xml.apache.org/axis/wsdd/";
            xmlns:java="http://xml.apache.org/axis/wsdd/providers/java";>
  <service name="TimsWS" provider="java:RPC">
    <parameter name="className" value="WebS1"/>
    <parameter name="allowedMethods" value="*"/>
<beanMapping qname="myNS:TestArray"  xmlns:myNS="urn:BeanService"
languageSpecificType="java:TestArray"/>
  </service>
</deployment>


//------------------------------  W S D L
--------------------------------
//
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions
targetNamespace="http://localhost:8080/axis/services/TimsWS";
xmlns="http://schemas.xmlsoap.org/wsdl/";
xmlns:apachesoap="http://xml.apache.org/xml-soap";
xmlns:impl="http://localhost:8080/axis/services/TimsWS";
xmlns:intf="http://localhost:8080/axis/services/TimsWS";
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/";
xmlns:tns1="urn:BeanService"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";><wsdl:types><schema
targetNamespace="urn:BeanService"
xmlns="http://www.w3.org/2001/XMLSchema";><import
namespace="http://schemas.xmlsoap.org/soap/encoding/"/><complexType
name="TestArray"><sequence><element name="attr1"
type="xsd:int"/><element name="attr2"
type="xsd:int"/></sequence></complexType></schema><schema
targetNamespace="http://localhost:8080/axis/services/TimsWS";
xmlns="http://www.w3.org/2001/XMLSchema";><import
namespace="http://schemas.xmlsoap.org/soap/encoding/"/><complexType
name="ArrayOf_tns1_TestArray"><complexContent><restriction
base="soapenc:Array"><attribute ref="soapenc:arrayType"
wsdl:arrayType="tns1:TestArray[]"/></restriction></complexContent></comp
lexType></schema></wsdl:types>
  <wsdl:message name="MyWSResponse">
    <wsdl:part name="MyWSReturn" type="impl:ArrayOf_tns1_TestArray"/>
  </wsdl:message>
  <wsdl:message name="MyWSRequest">
  </wsdl:message>
  <wsdl:portType name="WebS1">
    <wsdl:operation name="MyWS">
      <wsdl:input message="impl:MyWSRequest" name="MyWSRequest"/>
      <wsdl:output message="impl:MyWSResponse" name="MyWSResponse"/>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="TimsWSSoapBinding" type="impl:WebS1">
    <wsdlsoap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="MyWS">
      <wsdlsoap:operation soapAction=""/>
      <wsdl:input name="MyWSRequest">
        <wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";
namespace="http://DefaultNamespace"; use="encoded"/>
      </wsdl:input>
      <wsdl:output name="MyWSResponse">
        <wsdlsoap:body
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";
namespace="http://localhost:8080/axis/services/TimsWS"; use="encoded"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="WebS1Service">
    <wsdl:port binding="impl:TimsWSSoapBinding" name="TimsWS">
      <wsdlsoap:address
location="http://localhost:8080/axis/services/TimsWS"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>


--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .


Reply via email to