on 01-31-2007 9:59 AM
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.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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;
}
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
User | Count |
---|---|
86 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.