1 Reply Latest reply on May 12, 2004 7:27 PM by takenori

    type XML conversion ...

    alemito

      Hi,
      I have some problems in conversions ... I have only a method which takes an Integer and returns a Double array.
      I think XML doesn't like the array concept ...
      _____________________________________________________
      my web service:

      /*
      * Created on 12-mag-2004
      *
      * TODO To change the template for this generated file go to
      * Window - Preferences - Java - Code Generation - Code and Comments
      */
      /**
      * @author ale
      *
      * TODO To change the template for this generated type comment go to
      * Window - Preferences - Java - Code Generation - Code and Comments
      */
      public class Fibonacci {
      /**
      *
      */
      public Fibonacci() {
      super();
      // TODO Auto-generated constructor stub
      }

      public Double[] compute(Integer number) {
      int number_i=number.intValue();

      Double[] suite = new Double[number_i + 1];
      suite[0] = new Double(0);
      if (number_i == 0) {
      return suite;
      }
      suite[1] = new Double(1);
      for (int i = 2; i <= number_i; i++) {
      double primo=suite[i-1].doubleValue();
      double secondo=suite[i-2].doubleValue();
      double nuovo=primo+secondo;
      suite =new Double(nuovo);
      }
      return suite;

      }
      }
      __________________________________________________________
      my client:

      import org.apache.axis.client.Call;
      import org.apache.axis.client.Service;
      import javax.xml.rpc.ParameterMode;

      public class Client
      {
      public static void main(String [] args) {
      try {
      String endpoint =
      "http://localhost:8080/jboss-net/services/fibo";
      String methodName = "compute";

      Service service = new Service();
      Call call = (Call) service.createCall();

      call.setTargetEndpointAddress( new java.net.URL(endpoint) );
      call.setOperationName(methodName);

      // Call to addParameter/setReturnType as described in user-guide.html
      call.addParameter("number",
      org.apache.axis.Constants.XSD_INTEGER,
      ParameterMode.IN);
      call.setReturnType(org.apache.axis.Constants.XSD_DOUBLE);

      Integer i=new Integer(20);
      Object[] obj={i};

      Double[] ret =(Double[])call.invoke(obj);

      for(int j=0;j<ret.length;j++){
      System.out.println(ret[j]);
      }


      } catch (Exception e) {
      System.err.println(e.toString());
      }
      }
      }

      __________________________________________________________
      my error:

      Exception:
      org.xml.sax.SAXException: Bad types (class [Ljava.lang.Object; -> double)
      at org.apache.axis.message.RPCHandler.onStartChild(RPCHandler.java:311)
      at org.apache.axis.encoding.DeserializationContextImpl.startElement(DeserializationContextImpl.java:963)
      at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:198)
      at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:722)
      at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:233)
      at org.apache.axis.message.RPCElement.getParams(RPCElement.java:347)
      at org.apache.axis.client.Call.invoke(Call.java:2272)
      at org.apache.axis.client.Call.invoke(Call.java:2171)
      at org.apache.axis.client.Call.invoke(Call.java:1691)
      at Client.main(Client.java:28)
      org.xml.sax.SAXException: Bad types (class [Ljava.lang.Object; -> double)
      ____________________________________________________________

      thank you all

        • 1. Re: type XML conversion ...
          takenori

          Hi,

          How your java types map to SOAP/XML types in axis.
          You should use double, instead of Double.
          Please refer to axis user guid for details.
          http://ws.apache.org/axis/java/user-guide.html

          xsd:base64Binary byte[]
          xsd:boolean boolean
          xsd:byte byte
          xsd:dateTime java.util.Calendar
          xsd:decimal java.math.BigDecimal
          xsd:double double
          xsd:float float
          xsd:hexBinary byte[]
          xsd:int int
          xsd:integer java.math.BigInteger
          xsd:long long
          xsd:QName javax.xml.namespace.QName
          xsd:short short
          xsd:string java.lang.String