• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

xsd:anyType

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello fellow ranchers!

This is my question - might be something simple , might not..

So here is the input, I made a Web Service Provider - a simple method getPerson , that takes as input two Objects. (java.lang.Object) and output them to the response. Something like :

@WebService
public class Test{
public String getPerson(Object name, Object age){
return "Testing : " + name;
}
}

Deploy it in glassfish v3 (using Netbeans) and Test it, via: htpp://localhost:14200.....?Tester
I give the Web Service two objects that are required, but as a response I am getting "Testing : " null.

Does that mean that SOAP does know how to deal with java.lang.Objects during serialization and deserialization?

Or I do something wrong?

Thank you,
Eugene.
 
Ranch Hand
Posts: 268
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Does that mean that SOAP does know how to deal with java.lang.Objects during serialization and deserialization?


scratch your head once & say what do you think?


Default value of any object is null. Seems that is return in this case. Reason :


Or I do something wrong?


seems true
 
Eugene Rabii
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well I guess you are right - SOAP should know how to deal with java.lang.Object,

but why does it not return in to the response? If I change that to String - everything is ok.

I do not get your point about the default value thing...

Thank you,
Eugene.
 
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
Using the parameter type Object is not a good idea, since it will map to a custom JAXB type. When you later use it in your endpoint implementation class in this code:

Then the toString method will be called on an instance of the JAXB custom type, which does not know that you want to use it as a string.
JAX-WS and JAXB does know how to handle custom types, but they does not know how to read your mind.
Thus, if you want to use an object as a standard type, then type it as a standard type.
Note also that even though it is a SOAP web service, SOAP has nothing to do with handling custom types.

Additionally, to be picky: Your class is not a web service provider - it is a web service endpoint implementation class.
If you use the word "provider" when talking about a web service endpoint class developed in Java, people may thing that you mean an endpoint implementation class annotated with the @WebServiceProvider annotation that implements the Provider interface (see the JavaSE 6 API documentation for details).
Best wishes!
 
Eugene Rabii
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ups! Sorry about Provider stuff - I meant to say "Producer".
True, true about to String, but the problem is a bit misleading since I did not mention the problem as it is! I am sorry for that!

The stuff is actually a bit more complicated as it seems (at least to me) :

Now, here it is : I have made the same method to take as input 2 Objects. I expose the WSDL and build the client. Then I go back to the Producer and change the Objects to String and deploy it. If I try to consume this web service with soapUI (remember that WSDL is still xsd:anyType) , sopaUI does not know how to handle this "any:Type" that actually is a String and puts null instead. If I build a client (Java Code) - and pass two Strings it's all good!

I do not even know who to blame (soapUI for not knowing how to deal with xsd:anyType or ...) - of course I should NOT do stuff like redeploying the producer... but believe it or not this is my case in a future production environment and there is no way to change the WSDL to xsd:string!

Thank you for your help,
Eugene.
 
reply
    Bookmark Topic Watch Topic
  • New Topic