?
Solved

Sending an abstract argument to a web service

Posted on 2011-05-04
10
Medium Priority
?
596 Views
Last Modified: 2012-05-11
Can I send an abstract argument to a web service ?

Instead of having 2 web service methods
helloWorld(Teacher);
helloWorld(Student);

Can I have:
helloWorld(Person)



When Teacher & Student extend the abstract Person.

0
Comment
Question by:xcdev
  • 5
  • 3
  • 2
10 Comments
 

Author Comment

by:xcdev
ID: 35688444
I failed to note that I got the following exception when trying the above:


Unmarshalling Error: Unable to create an instance of Person





Is there a way to make it work with the abstract class?
0
 
LVL 47

Expert Comment

by:for_yan
ID: 35688466
Maybe you can make Person and Interface ?
0
 

Author Comment

by:xcdev
ID: 35688478
Didn't get your solution.


Can you explain it?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 47

Accepted Solution

by:
for_yan earned 750 total points
ID: 35688493
You can have Person as an interface which implements, say, methods
getName()
getAge()

Both Teacher and Student would be classes which implement tihis interface.

Then you can have parameter of type Person which you will be passing
to your remote method.


0
 
LVL 92

Assisted Solution

by:objects
objects earned 750 total points
ID: 35688498
as long as you include the concrete type in your request you should be ok
http://stackoverflow.com/questions/2688878/java-web-services-jaxb-abstract-superclass
0
 

Author Comment

by:xcdev
ID: 35688546
I have a slight mistake in my question.

the argument I send isn't ABSTRACT.

It's a regular good class which one of its members is abstract


0
 
LVL 47

Expert Comment

by:for_yan
ID: 35688559
That sounds strange.
You are probably rather sending an instance of a  class which inherits form abstract class.
0
 

Author Closing Comment

by:xcdev
ID: 35688602
After further investigation I am closing this question.

I'll re-post it after I'll figure my problem more accurately.
0
 
LVL 92

Expert Comment

by:objects
ID: 35688612
Same should apply as with my previous comment. Use @XmlSeeAlso to annotate the abstract class
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

While working on Silverlight and WCF application, I faced one issue where fault exception occurred at WCF operation contract is not getting propagated to Silverlight client. So after searching net I came to know that it was behavior by default for s…
In this post we will learn different types of Android Layout and some basics of an Android App.
This video teaches viewers about errors in exception handling.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month8 days, 13 hours left to enroll

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question