users@jax-ws.java.net

Problem with recursive/circular data references via SOAP

From: Francois Jean <fjean_at_dev.java.net>
Date: Mon, 6 Mar 2006 16:57:47 -0500

Hello,

I'm presently trying to implement a Web Service which exposes a class
with recursive/circular data references (see the code bellow).

When I'm calling the method testRecursive I got a "Stack Overflow
Exception" on the server side.

How can I represent circular/recursive references using JAX-WS?

François JEAN



package com.cardinal.ws.server;
import java.io.Serializable;
public class ClassA implements Serializable {
        private static final long serialVersionUID = 1L;
        private long id;
        private ClassA a;
        
        public ClassA getA() {
                return a;
        }
        public void setA(ClassA a) {
                this.a = a;
        }
        public long getId() {
                return id;
        }
        public void setId(long id) {
                this.id = id;
        }
}

        @WebMethod
        public ClassA testRecursive() {
                ClassA a1= new ClassA();
                ClassA a2= new ClassA();
                a1.setId(0);
                a1.setA(a2);
                
                a2.setId(1);
                a2.setA(a1);
                return a1;
        }