Hello,

I encountered a problem with the client of my axis web service, but I could also be a problem on the server side. A "Date[]" array is beeing transferred and the browser shows the fields correctly (as long as I can tell), but the client receives only one element instead of five. Something with the WSDL typeMapping or the axis client generation is malfunctioning, I would suggest.

Three questions arise:
1) Why don't get all Dates from the SOAP xsd:dateTime elements transferred into the date array on client-side?
2) Why is so much manual customization required?
3) Am I doing something wrong in my development process?


In the following I provide the necessary information related to this issue:
The service has a "History" class as part of the Interface(History class shown below), which has a "java.util.Date[]" field called "allCalibrations".

class History (web service):
import java.util.Date;
public class History {
    public Date lastCalibration      = null;
    public Date nextCalibration     = null;
    public Date[] allCalibrations    = null;
    ...
}


If the client sends its request, the response in the browser looks fine (SOAP Message shown below), it shows the five dates from the allCalibrations Date[] field.

SOAP Response of the web service request "getHistory" (browser):
<?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>
      <getHistoryResponse xmlns="">
        <ns1:getHistoryReturn xmlns:ns1="http://mdmonitor.webservice.qsgrimm.de">
          <ns1:lastCalibration xsi:type="xsd:date">2002-09-11</ns1:lastCalibration>
          <ns1:nextCalibration xsi:type="xsd:date">2002-09-11</ns1:nextCalibration>
          <ns1:allCalibrations xsi:type="xsd:date">1996-08-03</ns1:allCalibrations>
          <ns1:allCalibrations xsi:type="xsd:date">1997-09-16</ns1:allCalibrations>
          <ns1:allCalibrations xsi:type="xsd:date">1999-11-02</ns1:allCalibrations>
          <ns1:allCalibrations xsi:type="xsd:date">2001-02-09</ns1:allCalibrations>
          <ns1:allCalibrations xsi:type="xsd:date">2002-09-11</ns1:allCalibrations>
          ...
        </ns1:getHistoryReturn>
      </getHistoryResponse>
    </soapenv:Body>
  </soapenv:Envelope>


The web service WSDL, "History" complex type:
<complexType name="History">
  <sequence>
    <element name="lastCalibration" nillable="true" type="xsd:dateTime"/>
    <element name="nextCalibration" nillable="true" type="xsd:dateTime"/>
    <element name="allCalibrations" nillable="true" type="impl:ArrayOf_xsd_dateTime"/>
    ...
  </sequence>
</complexType>


The cause of the client only receiving a one field Date object in the allCalibrations field could be due to "deploy.wsdd"-file manipulations. Generating a wsdl file from the web service interface results in many typeMappings like the following. But a "de.qsgrimm.webservice.mdmonitor.GetJobs" class doesn't exist, so I removed all those entries.

TypeMapping, automatically generated by axis:
<typeMapping
        xmlns:ns="http://mdmonitor.webservice.qsgrimm.de"
        qname="ns:>getJobs"
        type="java:de.qsgrimm.webservice.mdmonitor.GetJobs"
        serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
        deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
        encodingStyle=""
/>

One entry was due to the Date array in the History class. The Mapping was the following:
ArrayTypeMapping, automatically generated by axis:
<arrayMapping
        xmlns:ns="http://mdmonitor.webservice.qsgrimm.de"
        qname="ns:ArrayOf_xsd_dateTime"
        type="java:java.util.Calendar[]"
        innerType="cmp-ns:dateTime" xmlns:cmp-ns="http://www.w3.org/2001/XMLSchema"
        encodingStyle=""
/>

But leaving the above statement in the deploy.wsdd, the field allCalibrations(Date[]) maps on client-side to:
private java.lang.Object[] allCalibrations;

Removing also the dateTime array mapping, results in a correct client-side-mapping as:
private java.util.Calendar[] allCalibrations;

but this configuration of History results in an exception thrown:
- Could not convert java.util.Date to bean field 'allCalibrations', type [Ljava.util.Calendar;
- Exception:
java.lang.IllegalArgumentException: argument type mismatch
    at org.apache.axis.encoding.ser.BeanPropertyTarget.set(BeanPropertyTarget.java:157)
   ...

So, I altered the History class on the client-side by hand to the following for the client to function properly. But it seems as only a (bad) workaround to me.
private java.util.Date[] allCalibrations;
while lastCalibration and nextCalibration last as:
java.util.Calendar xCalibration
...which seems to me quite weird, but functional.

Again the three questions:
1) Why don't get all Dates from the SOAP xsd:dateTime elements transferred into the date array on client-side?
2) Why is so much manual customization required?
3) Am I doing something wrong in my development process?



Thanks a lot for your help!
kind regards
Artur Kraft

Reply via email to