ws-soap-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexandros Panaretos" <>
Subject SOAP Serialization problem
Date Mon, 02 Sep 2002 15:03:43 GMT
Hi there,

I am quite new to SOAP and would like some help with the following if

Well, I am trying to pass my user defined object through SOAP. Now, I
have read various tutorials about passing user defined objects through
SOAP. From what I have understood there two ways of doing so:

A. Code your object class as a JavaBean and the use the provided
beanSerializer or
B. Create your own custom serializer & deserializer.

I am trying to do the first and I have a lot problems serializing the
following Java class:

<---------------  Start of Java Code ---------------->

import java.util.Vector;

public class MNistDataset implements ImageDataset {

    //InputStream is;
    //DataInputStream dis;

    //URL labelSetUrl;
    //URL imageSetUrl;

    String labelSetUrl;
    String imageSetUrl;

    byte[] labels;
    byte[] buf;

    Vector images;

    int maxPatterns = 1000000;
    int nImages;
    int nRows;
    int nCols;
    int nBytes;
    int nClasses;

    public MNistDataset(){


    public MNistDataset(String labelSetUrl, String imageSetUrl) throws
Exception {
        this.labelSetUrl = labelSetUrl;
        this.imageSetUrl = imageSetUrl;

    public MNistDataset(String labelSetUrl, String imageSetUrl, int
maxPatterns) throws Exception {
        this.labelSetUrl = labelSetUrl;
        this.imageSetUrl = imageSetUrl;
        this.maxPatterns = maxPatterns;

    public void readImageSet(String imageSetUrl) throws Exception {
        InputStream is;
        DataInputStream dis;

        is = new URL(imageSetUrl).openStream();
        dis = new DataInputStream(is);
        int magic = dis.readInt();
        //System.out.println("magic number is equal: " + magic);
        int n = dis.readInt();
        n = Math.min( maxPatterns , n );
        if (n != nImages) {
            throw new Exception(nImages + " <> " + n);
        nRows = dis.readInt();
        nCols = dis.readInt();
        images = new Vector();
        for (int i = 0; i < nImages; i++) {
            images.addElement(readImage(dis, nImages, nRows, nCols));



    public byte[][] readImage(DataInputStream dis, int nImages, int
nRows, int nCols) throws Exception {
        byte[][] imageByteArray = new byte[nRows][nCols];
        nBytes = nRows * nCols;
        buf = new byte[nBytes];, 0, nBytes);
        for (int x = 0; x < nRows; x++)  {
            for (int y = 0; y < nCols; y++) {
                imageByteArray[x][y] = buf[ x +  y * nRows];
        return imageByteArray;

    public byte[][] getImage(int i) {
        return (byte[][]) images.elementAt(i);

    public Object getPattern(int i) {
        return images.elementAt(i);

    public int getClass(int i) {
        return labels[i];

    public int nClasses() {
        return nClasses + 1;

    public int nPatterns() {
        return nImages;

    public ClassifiedDataset  emptyCopy() {
        // buggy - but probably not used!
        return this;


	I have ommitted the setters and getters of the class 
      variables in order to keep it short



<---------------  End of Java Code ---------------->

I already had a problem with the URLs and DataInputStream and
DataOutputStream variables so I declared within the methods rather than
global and I am not sure but I think SOAP can not handle the byte arrays
as properties of the JavaBean. Do you think there is a way of passing
this object through SOAP or is very complex and it can not serialize it?

Your help would be very much appreciated because this has been very
frustrating for me.

Thank you very much in advance for patience in reading this post and
your help.

Alexandros Panaretos

View raw message