Click to See Complete Forum and Search --> : web service returntype problem


almanden
03-02-2009, 05:36 AM
Hi all,
Is it possible to use java.util.Properties as return type of a service operation?
in any type of services
thanks in advance

chazzy
03-02-2009, 12:50 PM
i don't see why not. @WebResult should work fine.

almanden
03-03-2009, 12:45 AM
chazzy thanks to reply.
return tag in soap response is null.but when I test the web service I get some thing like "java.util.Properties@xxxxxx" in return value, where xxxxxx is a number.
I dont know how i can use "Properties","Hashtable","Dictionary" type which become available in my own pakage to getting the return values.
I should mention that return type of operation is Properties
I could not find any simple instruction or even sample
could any one help me?

almanden
03-03-2009, 02:21 AM
chazzy thanks to reply.
return tag in soap response is null.but when I test the web service I get some thing like "mypakage.Properties@xxxxxx" in return value,xxxxxx is similar to "fed246"
I dont know how i can use "Properties","Hashtable","Dictionary" type which become available in my own pakage to getting the return values.
and also i do not know whether SEI has annotated correctly(annotation on operation: @WebMethod,@WebResult,@ResponseWrapper) regarding to null return tag.
I should mention that return type of operation is Properties
I could not find any simple instruction or even sample
could any one help me?

correction to previous post!

chazzy
03-03-2009, 05:18 AM
getting java.util.properties@xxxxxx is simply the "toString" of the properties object. without knowing how the client was coded, it's hard to determine where the error might be, if any at all. did you use the built in tools in your app server to generate the client?

almanden
03-03-2009, 05:37 AM
getting java.util.properties@xxxxxx is simply the "toString" of the properties object. without knowing how the client was coded, it's hard to determine where the error might be, if any at all. did you use the built in tools in your app server to generate the client?

I am using netbeans 6.5 and glassfish.
service class:


@Stateless
@WebService
public class CustomersSessionBean implements CustomersSessionRemote {
.
.
.



and the operation:


@WebMethod
@WebResult(name="testResult" ,targetNamespace="http://proj.ejb.almanden/")
@ResponseWrapper(className="almanden.ejb.proj.CustomersSessionBeanService",localName="testResponse",targetNamespace="http://proj.ejb.almanden/")
public Properties test()
{
Properties ppp=new Properties();
ppp.put("GOD", "pray");
return ppp;
}

and at client side I add a new>web service client using netbeans


almanden.ejb.proj.CustomersSessionBeanService service;



almanden.ejb.proj.CustomersSessionBean csb=service.getCustomersSessionBeanPort();



at this level I dont know how to get my data
some new classes are generated in almanden.ejb.proj package
such as Properties,Hashtable,Dictionary
I think I should use these classes somehow.
I am getting confused completely

almanden
03-03-2009, 06:56 AM
This is the SOAP response message:

<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:testResponse xmlns:ns2="http://proj.ejb.almanden/">
<ns2:testResult/>
</ns2:testResponse>
</S:Body>
</S:Envelope>

Any help appreciated!

chazzy
03-03-2009, 10:00 AM
i think you should start with this page, and a lot of the links on it

http://www.netbeans.org/kb/60/websvc/intro-ws.html

almanden
03-04-2009, 05:46 AM
i think you should start with this page, and a lot of the links on it

http://www.netbeans.org/kb/60/websvc/intro-ws.html

thank you for link,
i've read them,but they dont solve my problem.
I can use String int ,etc as return type but problem is still on Properties.
I dont know why response soap return tag is empty.
when i use .toString on operation I get
"myPackage.Properties@77af84" on the client side.
could you explain more?
it is a great boon.
sorry for my bad english.

almanden
03-05-2009, 11:45 AM
no idea or it is very very simple?

chazzy
03-05-2009, 06:52 PM
sorry, needed time to think. could you please post both your client and server code?

almanden
03-06-2009, 12:28 AM
i've uploaded enterprise project which i created in the netbeans IDE here (http://ifile.it/38dzsye)
both client and server.
it is great job chazzy,thank you so much

chazzy
03-06-2009, 04:50 AM
ok and based on what your code is doing, you should see a page that has the word "pray" written on it twice. is this not what you see?

Edit: also, depending on your container (and really to be truly compliant w/ java ee) you need to have your webservice implement a Remote interface that you define that's annotated @Remote

almanden
03-07-2009, 06:01 AM
i've tested annotated @Remote on the interface but it did not work
chazzy, are you sure that it is possible for an operation to return java.util.Properties?

chazzy
03-07-2009, 06:11 AM
seeing as how i took your project, deployed it, and it worked fine, yes.

chazzy
03-07-2009, 07:33 AM
ok, i lied (only kind of)

when i ran it, i ran it on a different app server which doesn't have to be 100% compliant. based on the spec all collections (everything derived from java.util.Collection or java.util.Map) are removed. see a full list of types: http://java.sun.com/javaee/5/docs/tutorial/doc/bnazq.html#bnazs

almanden
03-08-2009, 01:38 AM
Thank you so much for replying chazzy.
ok,according to the tables on the page you linked,it is not possible to use java.util.Properties by default.
Am i correct?
ok,if answer is yes ,I will find myself in a confusing situation because i cant understand why mypackage.Hashtable,mypackage.Properties,.. are appear in my package while jaxb could not bind this data types.

chazzy
03-08-2009, 06:49 AM
the creation of those types is how glassfish attempts to deal with the fact that it can't send a Map over. it obviously fails because neither type has any methods associated with it. what i would recommend, if you really have to send a Map over (stop trying to think of it as a Properties object, too difficult, use Map<String, String>), you could get the Entry set (getEntrySet, returns a Set of Entry<String,String> objects), then use Arrays to convert it to an array, return the array. glassfish should be able to deal with that.