on 10-19-2009 8:30 AM
Hi all,
I've an EJB which exposes some business methods as Web Service.
One parameter of a business method is an array of an interface called IPair (which is actually an interface that a class called Pair implements) - see code:
public int createRequest3( // Business method
String userID,
int formID,
IPair[] pairs,
String comment,
int linkedRequestID,
String theYear) {
// TODO : Implement
return 999;
}
public interface IPair {
public String getKey();
public String getValue();
public void setKey(String string);
public void setValue(String string);
}
public class Pair implements IPair, Serializable {
private String key;
private String value;
public String getKey() {
return key;
}
public String getValue() {
return value;
}
public void setKey(String string) {
key = string;
}
public void setValue(String string) {
value = string;
}
}
When I test it by using WSNavigator I can choose between IPair & Pair and if I select Pair the method works.
WSNavigator screen shot: http://img7.imageshack.us/i/pairp.jpg/
When I import it to Web Dynpro only the IPair interface is imported and since I cannot create an instance of Pair I get an exception:
Caused by: java.lang.reflect.InvocationTargetException: Deserializing fails. Nested message: XML Deserialization Error. Can not create instance of class [w.x.y.x.interfaces.IPair] when deserializing XML type [urn:w.x.y.x.interfaces][IPair]..
If I use the deprecated Web Service model everything works because both IPair and Pair are generated in the WD side (it seems that WSNavigator works like the deprecated Web Service Model in WD).
How can I use this kind of complex type when using the Adaptive Web Service Model?
Regards,
Omri
Hi,
The interface IPair should extend Serializable or Externalizable too.
Regards,
Satyajit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Satyajit Chakraborty,
Thanks for your help.
I'm extending now IPair:
public interface IPair extends Serializable {
public String getKey();
public String getValue();
public void setKey(String string);
public void setValue(String string);
}
The problem remains.
In pic1 you can see what happens when using class (the way it should be):
http://img16.imageshack.us/i/classfw.jpg/
In pic2 you can see what happens when using interface (this is what WD does - in WD I can't choose between the class or the interface, only 'IPair' is created by the adaptive web service model) and this is the exact exception I'm getting when I run it from WD.
http://img24.imageshack.us/i/interfacexw.jpg/
Deprecated model still works...
Regards,
Omri
Hi,
Are you using JavaEE 5 or above? If yes then you should try using the @XmlJavaTypeAdapter annotation. You can find more details [here|https://jaxb.dev.java.net/guide/Mapping_interfaces.html].
If not then try using an abstract class instead of an interface like so:
public abstract class AbstractPair implements Serializable {
public String getKey();
public String getValue();
public void setKey(String string);
public void setValue(String string);
}
Regards,
Satyajit
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.