History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: XFIRE-826
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Dan Diephouse
Reporter: Frank Hemer
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
XFire

Problem writing byte array of size zero

Created: 07/Jan/07 07:41 AM   Updated: 21/Jan/07 02:11 PM
Component/s: None
Affects Version/s: 1.2.3
Fix Version/s: 1.2.5

Time Tracking:
Not Specified

Testcase included: yes


 Description  « Hide
xfire1.2.3, aegis binding.

The following code causes trouble if one of the byte arrays is of size zero in
the Container class. As a result, either a Fault or an invalid number of
Containers is received on the other side.

The server I tested this simply echos the result ...

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

import org.codehaus.xfire.service.binding.ObjectServiceFactory;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.client.XFireProxyFactory;
import org.codehaus.xfire.transport.Channel;

public class Test {

public static void main (String [] args) {
try { Class serviceCallback = Callback.class; ObjectServiceFactory serviceFactory = new ObjectServiceFactory (); Service serviceModel = serviceFactory.create (serviceCallback); XFireProxyFactory proxyFactory = new XFireProxyFactory (); Callback testCallback = (Callback) proxyFactory.create(serviceModel, "localhost:8080/" + serviceCallback.getName ()); Container [] containers = new Container [2]; System.out.println ("C DSPExternalTest::containerTest"); containers [0] = new Container (); containers [0].myField = 3; containers [0].myArray = new byte [0];//causes trouble containers [1] = new Container (); containers [1].myField = 4; containers [1].myArray = new byte [2]; containers = testCallback.containerTest (containers); System.out.println ("Containers: "+containers.length); System.out.println ("Containers1: "+containers [0].myField); System.out.println ("Containers2: "+containers [1].myField); System.out.println ("Containers1: "+containers [0].myArray.length); System.out.println ("Containers2: "+containers [1].myArray.length); } catch (Exception e) { e.printStackTrace (); }
}
}

public class Container implements java.io.Serializable {

public Container () {
}

public int myField;

public byte [] myArray;

public int getMyField () { return myField; }

public void setMyField (int field) { myField = field; }

public byte [] getMyArray () { return myArray; }

public void setMyArray (byte [] array) { myArray = array; }
}

public interface Callback {
Container [] containerTest (Container [] containers) throws Exception;
}

public class CallbackImpl implements Callback {
public Container [] containerTest (Container [] containers) throws
Exception { System.out.println ("S CallbackImpl::containerTest"); System.out.println ("Containers: "+containers.length); System.out.println ("Containers1: "+containers [0].myField); System.out.println ("Containers2: "+containers [1].myField); System.out.println ("Containers1: "+containers [0].myArray.length); System.out.println ("Containers2: "+containers [1].myArray.length); return containers; }

}

And here's the wsdl:


<wsdl:definitions targetNamespace="http://DefaultNamespace">

<wsdl:types>

<xsd:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://DefaultNamespace">

<xsd:complexType name="ArrayOfContainer">

<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="Container" nillable="true" type="tns:Container"/>
</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="Container">

<xsd:sequence>
<xsd:element minOccurs="0" name="myArray" nillable="true" type="xsd:base64Binary"/>
<xsd:element minOccurs="0" name="myField" type="xsd:int"/>
</xsd:sequence>
</xsd:complexType>

<xsd:element name="containerTest">

<xsd:complexType>

<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="in0" nillable="true" type="tns:ArrayOfContainer"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>

<xsd:element name="containerTestResponse">

<xsd:complexType>

<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="out" nillable="true" type="tns:ArrayOfContainer"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>

<wsdl:message name="containerTestRequest">
<wsdl:part name="parameters" element="tns:containerTest"/>
</wsdl:message>

<wsdl:message name="containerTestResponse">
<wsdl:part name="parameters" element="tns:containerTestResponse"/>
</wsdl:message>

<wsdl:portType name="CallbackPortType">

<wsdl:operation name="containerTest">
<wsdl:input name="containerTestRequest" message="tns:containerTestRequest"/>
<wsdl:output name="containerTestResponse" message="tns:containerTestResponse"/>
</wsdl:operation>
</wsdl:portType>

<wsdl:binding name="CallbackHttpBinding" type="tns:CallbackPortType">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>

<wsdl:operation name="containerTest">
<wsdlsoap:operation soapAction=""/>

<wsdl:input name="containerTestRequest">
<wsdlsoap:body use="literal"/>
</wsdl:input>

<wsdl:output name="containerTestResponse">
<wsdlsoap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>

<wsdl:service name="Callback">

<wsdl:port name="CallbackHttpPort" binding="tns:CallbackHttpBinding">
<wsdlsoap:address location="http://localhost/services/Callback"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Dan Diephouse - 08/Jan/07 07:01 AM
Thanks! Scheduling for 1.2.5 (1.2.4 was cut over the weekend and will be announced today).

Dan Diephouse - 21/Jan/07 02:11 PM
Thanks, I've fixed this in SVN and will post a snapshot soon (by tomorrow) with the fix.