Hi Bill,
 
I use ArrayList. I wrapp the ArrayList inside a Complex type called Request. I pass the Request as an input to my remote operation. I originally couldn't do this but thanks to Vanketesh I figured out. Attached are my client code and the wsdl.
 
Let me know if you need anything else.
 
Cheers,
Tony.
 


"Heitzeg, Bill" <[EMAIL PROTECTED]> wrote:
It does, thanks Tony!
 
    I think from my research that this is either a bug in Axis or no one has figured out how to do it correctly.  It's strange because Arrays work great as a top level parameter and also nested in the response.  The only thing that doesn't work is nesting in the request.  I've read several times where people have given up on arrays and decided to use something else.  Has this caused any interop problems for you?  I would probably use an ArrayList, is that what you used?  Would you mind sending me a code snippet and a snippet of your wsdd?  I just want to get this right, it's really slowing me down and I need to move on.
 
thanks for you time, I really appreciate it.
 
Bill
-----Original Message-----
From: Tony Blair [mailto:[EMAIL PROTECTED]
Sent: Tuesday, February 10, 2004 12:01 PM
To: [EMAIL PROTECTED]
Subject: Re: Simple arrays in complex types

Bill,
 
I have a similar code where I pass in a Collection (as oppose to an array) of beans inside a complex type as a method parameter to an operation. It works fine but I had to provide a QName and register the type mapping with the Call object inside my Client code.
 
Hope this helps,
Tony.

"Heitzeg, Bill" <[EMAIL PROTECTED]> wrote:
Hello everyone, well at least Monday is over,

I'm having a problem when I place a String array inside of a complex type. If I just want to send a String Array as a method parameter, it works fine. As soon as I place the array inside of complex type I get a NullPointerException. This is happening before my code is called. Also, if I don't populate the array with any values (xsi:nil="true"), it works fine. Has anyone else had this problem? Any advice you might have would be great. The WSDL is at the bottom of this email, it's auto generated by Axis.

thanks,

Bill Heitzeg


Request Message:


xmlns:impl="http://localhost:8080/BillWebService_axis/services/BillWebService"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tns1="urn:prototype:webservices:cruise:sabre:com"
xmlns:tns3="http://prototype.webservices.cruise.sabre.com" xmlns:xs="http://www.w3.org/2001/XMLSchema">



Bill Heitzeg

995-9125
995-9131






Response Message:




soapenv:Server.userException
java.lang.NullPointerException





WSDL

























































































































































Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online


Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online
  <?xml version="1.0" encoding="UTF-8" ?> 
- <wsdl:definitions targetNamespace="http://localhost:8080/axis/services/PublicService4"; xmlns="http://schemas.xmlsoap.org/wsdl/"; xmlns:apachesoap="http://xml.apache.org/xml-soap"; xmlns:impl="http://localhost:8080/axis/services/PublicService4"; xmlns:intf="http://localhost:8080/axis/services/PublicService4"; xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"; xmlns:tns1="urn:PublicService4" xmlns:tns2="http://apacheaxis"; 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:PublicService4" xmlns="http://www.w3.org/2001/XMLSchema";>
- <complexType name="Param">
- <sequence>
  <element name="name" nillable="true" type="xsd:string" /> 
  <element name="value" nillable="true" type="xsd:anyType" /> 
  </sequence>
  </complexType>
- <complexType name="Request">
- <sequence>
  <element name="params" nillable="true" type="soapenc:Array" /> 
  </sequence>
  </complexType>
- <complexType name="Response">
- <complexContent>
- <extension base="tns1:Request">
  <sequence /> 
  </extension>
  </complexContent>
  </complexType>
  </schema>
- <schema targetNamespace="http://apacheaxis"; xmlns="http://www.w3.org/2001/XMLSchema";>
- <element name="getSeveralBusinessLocation">
- <complexType>
- <sequence>
  <element name="in0" type="tns1:Request" /> 
  </sequence>
  </complexType>
  </element>
- <element name="getSeveralBusinessLocationResponse">
- <complexType>
- <sequence>
  <element name="getSeveralBusinessLocationReturn" type="tns1:Response" /> 
  </sequence>
  </complexType>
  </element>
  </schema>
  </wsdl:types>
- <wsdl:message name="getSeveralBusinessLocationRequest">
  <wsdl:part element="tns2:getSeveralBusinessLocation" name="parameters" /> 
  </wsdl:message>
- <wsdl:message name="getSeveralBusinessLocationResponse">
  <wsdl:part element="tns2:getSeveralBusinessLocationResponse" name="parameters" /> 
  </wsdl:message>
- <wsdl:portType name="PublicService4">
- <wsdl:operation name="getSeveralBusinessLocation" parameterOrder="">
  <wsdl:input message="impl:getSeveralBusinessLocationRequest" name="getSeveralBusinessLocationRequest" /> 
  <wsdl:output message="impl:getSeveralBusinessLocationResponse" name="getSeveralBusinessLocationResponse" /> 
  </wsdl:operation>
  </wsdl:portType>
- <wsdl:binding name="PublicService4SoapBinding" type="impl:PublicService4">
  <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"; /> 
- <wsdl:operation name="getSeveralBusinessLocation">
  <wsdlsoap:operation soapAction="" /> 
- <wsdl:input name="getSeveralBusinessLocationRequest">
  <wsdlsoap:body namespace="http://apacheaxis"; use="literal" /> 
  </wsdl:input>
- <wsdl:output name="getSeveralBusinessLocationResponse">
  <wsdlsoap:body namespace="http://localhost:8080/axis/services/PublicService4"; use="literal" /> 
  </wsdl:output>
  </wsdl:operation>
  </wsdl:binding>
- <wsdl:service name="PublicService4Service">
- <wsdl:port binding="impl:PublicService4SoapBinding" name="PublicService4">
  <wsdlsoap:address location="http://localhost:8080/axis/services/PublicService4"; /> 
  </wsdl:port>
  </wsdl:service>
  </wsdl:definitions>
package apacheaxis;

import org.apache.axis.AxisFault;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.utils.Options;

import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import java.util.*;
                                           
public class Client
{
    public static void main(String [] args) throws Exception
    {
        Options options = new Options(args);
        
        Request req = new Request();
        Param inp1 = new Param();
        inp1.setName("some name 1");
        inp1.setValue("some value 1");

        Param inp2 = new Param();
        inp2.setName("some name 2");
        inp2.setValue("some value 2");

        ArrayList inparams = new ArrayList(3);
        inparams.add(inp1);
        inparams.add(inp2);

        req.setParams(inparams);
        
        Service  service = new Service();
        Call     call    = (Call) service.createCall();

        QName qn      = new QName( "urn:PublicService4", "Request" );
        call.registerTypeMapping(Request.class, qn,
                      new org.apache.axis.encoding.ser.BeanSerializerFactory(Request.class, qn),        
                      new org.apache.axis.encoding.ser.BeanDeserializerFactory(Request.class, qn));

        QName qn1      = new QName( "urn:PublicService4", "Response" );
        call.registerTypeMapping(Response.class, qn1,
                      new org.apache.axis.encoding.ser.BeanSerializerFactory(Response.class, qn1),        
                      new org.apache.axis.encoding.ser.BeanDeserializerFactory(Response.class, qn1));

        QName qn2= new QName( "urn:PublicService4", "Param" );

        call.registerTypeMapping(Param.class, qn2,
                      new org.apache.axis.encoding.ser.BeanSerializerFactory(Param.class, qn2),        
                      new org.apache.axis.encoding.ser.BeanDeserializerFactory(Param.class, qn2));        

        Response resp=null;
        try {
            String url = options.getURL();
            System.out.println("URL:"+ url);
            call.setTargetEndpointAddress( new java.net.URL(url) );
            call.setOperationName( new QName("PublicService4", "getSeveralBusinessLocation") );
            call.addParameter( "arg1", qn, ParameterMode.IN );
            call.setReturnClass(Response.class);
            resp = (Response) call.invoke( new Object[] { req } );
        } catch (AxisFault fault) {
          String  error = "Error : " + fault.toString();
          System.out.println(error);
        }
        System.out.println("Name               Value");
        System.out.println("------------------------");
        Collection result = resp.getParams();
        Iterator itr = result.iterator();
        while(itr.hasNext()){
            Param p = (Param)itr.next();
            String name = p.getName();
            String value = (String)p.getValue();
            System.out.println(name+"       "+value);

        }
    }
}

Reply via email to