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 Dimuthu Leelarathne <mu...@vijayaba.cse.mrt.ac.lk> on 2002/10/02 06:06:30 UTC

Re: ComplexType Array

ComplexType ArrayTim

Check out this bug;

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15384

Regards,
Dimuthu.

----- Original Message -----
From: Cobble, Tim
To: axis-user@ws.apache.org
Sent: Thursday, October 02, 2003 12:23 AM
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></complexT
ype></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>