aspose file tools*
The moose likes Web Services Certification (SCDJWS/OCEJWSD) and the fly likes xsd:anyType Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Services Certification (SCDJWS/OCEJWSD)
Bookmark "xsd:anyType" Watch "xsd:anyType" New topic
Author

xsd:anyType

Eugene Rabii
Ranch Hand

Joined: Apr 24, 2009
Posts: 30
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.
Deepika Joshi
Ranch Hand

Joined: Feb 24, 2009
Posts: 268

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

Joined: Apr 24, 2009
Posts: 30
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.
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
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

Joined: Apr 24, 2009
Posts: 30
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: xsd:anyType