cancel
Showing results for 
Search instead for 
Did you mean: 

Writing a web service that returns a table

Former Member
0 Kudos

Hello Experts,

I'm a bit new to J2EE programing and will appreciate your help.

The main question is:

What is the best way to return a table from a web service?

In details:

I wrote an EJB calling an RFC.

The RFC returns a table.

I've created a web service from this EJB and need to return the above table as an output parameter.

What is the best way of passing the JCO.Table as an output parameter?

Should I pass it as an Object (and the client will take care of the casting)

or - is there a simple type I should convert the table to before passing it?

Thanks for your help, Adi.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Adi,

The way I always return a JCO table in my Webservice Interface is returning an Interface.

Say you JCO table is a Person with different attributes in it.

Then I create an Interface IPerson with methods like

public abstract String getName(); etc.

I also create an object Person with methods:

public String getName() {

return name;

}

In my bean the I have a method:

public IPerson getJCOPerson() {

//retrieve the JCO table person

IPerson pers = new Person();

pers.setName(//name from JCO table);

etc.

return pers;

}

I hope this helps you further.

Former Member
0 Kudos

Hi B. van Prooijen,

Thanks for your fast response.

I'm not sure that I understood your answer.

You have a table - each record represents one person's details.

with your Web Service you return each time only one record from the table?

I need to return a whole table.

If I'm completely wrong here - What is the type of your output parameter?

Thanks, Adi.

PS : What if I want .Net programmers to use that Interface (IPerson) ?

Message was edited by:

Adi Shmidman

Former Member
0 Kudos

Oh sorry of course you have a list of Person's then.

Then you iterate through your table and in you method signature you return a array of IPerson:

public IPerson[] getJCOPerson() {

//retrieve the JCO table person

for (Jco table size) {

IPerson pers = new Person();

pers.setName(//name from JCO table);

etc.

personArray.add(pers)

}

return personArray;

}

Former Member
0 Kudos

O.K. I return an array of objects and the client will make casting for Iperson?

The thing I don't understand is:

How will this Iperson interface be known at the client?

what if the client is a .Net project?

Thanks, Adi

Former Member
0 Kudos

Hi,

If you are finished with your Webservice and are sure that everything works as espected (You can test your Webservice in the Webservice Navigator in the portal) then you can give your .wsdl file to your client.

If your client is a Java client they can generate a .jar with the tool wsdl2java.

I'm think there's also a tool for example for .NET.

You don't have to worrie about that part > .NET guys sure knows what to do with your .wsdl file > This is the blueprint for your webservice!

If the client has generated there code from the .wsdl file they can also see then that your webservice returns an Object from the type IPerson[].

Regards

Former Member
0 Kudos

Hi Adi,

Did you allready resolve this problem?

Former Member
0 Kudos

Hi again B. van Prooijen,

My solution was to send the table is as an XML String.

It just seemed much faster and easier to implement both form my side as the Web service developer and both from the client side.

Thanks for your help.

Still open to hear about a better solution though...

Adi.