[
http://jira.jboss.com/jira/browse/JBWS-1702?page=comments#action_12373696 ]
Marco Strauch commented on JBWS-1702:
-------------------------------------
Hi,
I tried it with @XmlSeeAlso but it does not work. For an example I created 2 classes -
PO_S_Class and PO_SC_Repository and a POJO based WebService. See below code:
PO_S_Class:
-------------------
@XmlType(name="PO_S_Class")
@XmlAccessorType(value=XmlAccessType.FIELD)
@XmlSeeAlso(value=PO_SC_Repository.class)
public class PO_S_Class {
// 2 sample attributes
private String name;
private String shortName;
@XmlElement(name="intValue", nillable=true, required=true)
private Integer intValue;
// --> here are the setter and getter methods
}
PO_SC_Repository
---------------------------
@XmlAccessorType(value=XmlAccessType.FIELD)
@XmlType(name="PO_SC_Repository")
public class PO_SC_Repository extends PO_S_Class {
private String scAttr;
// --> here are getter and setter methods
}
WebService:
-----------------
@WebService(name="MyWebService", serviceName="MyWebService",
targetNamespace = "http://examples.ws")
@SOAPBinding( style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL,
parameterStyle = SOAPBinding.ParameterStyle.WRAPPED )
public class MyWebService {
public MyWebService() {
}
@WebMethod
@WebResult( name = "result", targetNamespace =
"http://examples.ws/types" )
public PO_S_Class getPOSClass() {
PO_SC_Repository c = new PO_SC_Repository();
c.setName("Test");
c.setShortName("TST");
c.setIntValue(10);
c.setScAttr("strAttr");
return c;
}
}
-----------------------------------
I test it with 2 clients: A Java client and a .Net Client (written in #C). Both clients
bring different results:
1. Java Client
------------------
I used wsconsume to create the web service artifacts of the generated wsdl (Generated of
JBossWS during deployment).
Code:
--------
MyWebService_Service service = new MyWebService_Service(new
URL("http://wmdmst:8080/WS/MyWebService?wsdl"), new QName(
"http://examples.ws", "MyWebService"));
MyWebService port = service.getMyWebServicePort();
POSClass c = port.getPOSClass(); // --> works fine
System.out.println(c.getName());
POSCRepository c2 = (POSCRepository) c; // --> results in ClassCastException
System.out.println(c2.getScAttr());
2. .Net Client
------------------
I created the artifacts with visual studio and follow code to access the web service:
MyWebService.MyWebService myWs = new MyWebService.MyWebService();
MyWebService.getPOSClass param1 = new
DevTestClient.MyWebService.getPOSClass();
MyWebService.getPOSClassResponse resp = myWs.getPOSClass(param1); //
--> InvalidOperationException occurs
MyWebService.PO_SC_Repository c = (MyWebService.PO_SC_Repository)resp.result;
The inner exception was: {"The specified type was not recognized:
name='PO_SC_Repository', namespace='', at <result
xmlns='http://marabu.pegasos.pos/types'>."}
So what I make wrong. Please help me. I have no solution anymore.
Kind Regards Marco.
JAXWS type inheritance
----------------------
Key: JBWS-1702
URL:
http://jira.jboss.com/jira/browse/JBWS-1702
Project: JBoss Web Services
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: jbossws-jaxws
Reporter: Thomas Diesler
Assigned To: Heiko Braun
Fix For: jbossws-2.0.1
Attachments: WSSampleApp.zip
I have a problem with the new JBossWS-1.2.1.GA in JBoss 4.2.0.GA and inheritance.
To describe this problem first I have to describe my code structure:
For an example I have three classes (ClassA, ClassB and ClassC). ClassC inherits of
ClassB and ClassB inherits of ClassA (ClassA --> ClassB --> ClassC). Now I have a
webservice method that returns ClassB. In this method an instance of ClassC is being
created and returned. This was not a problem in the former JBossWS version (and also in
the other J2EE 4 styled webservices) but now in JBossWS 1.2 I only get returned an object
of ClassB but I supposed to get an obejct of ClassC.
Code:
public class ClassA {
private String propA;
// here setter and getter for propA
......
}
public class ClassB extends ClassA {
private String propB;
// here setter and getter for propB
......
}
public class ClassC extends ClassC {
private String propC;
// here setter and getter for propC
......
}
@WebService
@SOAPBinding( style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL,
parameterStyle = SO
APBinding.ParameterStyle.WRAPPED )
public class MyWebService {
@WebMethod()
public ClassB getClassB() {
ClassC classC = new ClassC();
classC.setPropA("propA");
return classC;
}
/**
* --> this method is only used to publish ClassC otherwise it is not known
* in this webservice
*/
@WebMethod()
public ClassC getClassC() {
ClassC classC = new ClassC();
classC.setPropA("propA");
return classC;
}
}
}
Now I call getClassB() and the result that I got is an object of ClassB and not of
ClassC.
What can I do to get an object of ClassC. I also looked at the returned SOAP message and
there you can see that only informations about the ClassB instance are submitted. In JBoss
4.0.5 (JBossWS1.0.3) the SOAP message contains the type of the returned object and all
data are being submitted correctly.
I also tried the SOAP parameter style BARE but nothing changed. And whenI use RPC/Literal
then I get an error in the .NET Client that an instance of ClassB was expected but got an
instance of ClassC. I also tried it with a JAVA client but there was the same occurance.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira