-
1. Re: Type Substitution doesn't work with Schema2Java Client a
m_schumpa Aug 15, 2007 10:31 AM (in response to m_schumpa)hi again,
no one here who can help me with this issue?
Maybe my description of the problem is hard to understand. so I'll try to make it more clear.
First I have written a web service with a parameter and a return value.
the method is something like:
returnValue calculate (List<Car> carList){...}
The parameter is something like:
class car{...}
class cheep extends car{...}
class cabrio extends car{...}
so I added the @XmlSeeAlso ({cheep.class, cabrio.class}) annotation to the Car class.
I can now deploy the web service and the wsdl gets generated in a proper way.
The first thing I did to test the service was writting a simple client which creates a cheep and a cabrio instance and adds these two instances to a list and passes it to the web service. For this I used the classes I coded.
With this setup everything worked fine and the service was able to cast the list members to the proper type. So the type substitution worked well.
But I need the test the Schema2Java approach, too.
So I consumed the WSDL with wsconsume and the -t 2.1 switch.
I addopted the client to use the generated classes. But here the type substitution doesn't work. Only a list of car instances gets passed to the service.
Anybody here who has a clue on how to fix this problem?
Thanks in advance.
Greetings
m_schumpa -
2. Re: Type Substitution doesn't work with Schema2Java Client a
thomas.diesler Aug 17, 2007 8:47 AM (in response to m_schumpa)What's the difference in hand coded vs. generated classes?
-
3. Re: Type Substitution doesn't work with Schema2Java Client a
m_schumpa Aug 20, 2007 10:27 AM (in response to m_schumpa)There are no big differences...
The attributes are all named the same; in handcoded they're private, in generated they're protected.
In the genareted classes there are the @XmlAccessorType, @XmlType and @XmlElement annotations, in handcoded not.
In the handcoded classes I've added toString() methods (for logging), which aren't present in the generated classes
The generated classes didn't have a setter method for lists, so I added them.
That's all the differences I was able to find.
But as I said before the problem only exists in JBoss, with Glassfish everything works fine, even if I use the classes generated with the JBoss wsconsume tool. -
4. Re: Type Substitution doesn't work with Schema2Java Client a
hannes.koller Aug 22, 2007 8:08 AM (in response to m_schumpa)I think this might be related to this:
http://www.jboss.org/index.html?module=bb&op=viewtopic&t=110260
As it seems this was a bug (http://jira.jboss.org/jira/browse/JBWS-1702) and hopefully should be fixed in JBossWS 2.0.0.GA -
5. Re: Type Substitution doesn't work with Schema2Java Client a
m_schumpa Aug 22, 2007 10:15 AM (in response to m_schumpa)I'm already using the JBossWS 2.0.0.GA modul.
-
6. Re: Type Substitution doesn't work with Schema2Java Client a
thomas.diesler Aug 23, 2007 8:20 AM (in response to m_schumpa)Please create a jira issue for that and attach a test case that allows us to reproduce what you are seeing
-
7. Re: Type Substitution doesn't work with Schema2Java Client a
m_schumpa Aug 23, 2007 12:06 PM (in response to m_schumpa)I've added a jira issue and added a test case. Here's the link:
http://jira.jboss.org/jira/browse/JBWS-1795 -
8. Re: Type Substitution doesn't work with Schema2Java Client a
m_schumpa Aug 29, 2007 4:20 AM (in response to m_schumpa)hi thomas,
do you think there is a quick fix for this problem?
I'm asking because I'm writing a diploma thesis about Web Services and the deadline is the end of september. -
9. Re: Type Substitution doesn't work with Schema2Java Client a
klease Sep 11, 2007 5:50 PM (in response to m_schumpa)This seemed similar to some problems I had so I ran your test case and looked at the soap messages which were generated.
The handcoded case which works has this in the message.<list xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:type='cabin'>
The generated case which fails has this:<list xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:type='ns1:cabin'>
The namespace prefix ns1 is defined on the parent, so it looks like it should be fine.
But when it gets decoded in the service, it loses the type information and only gets objects of your base class. When there is no namespace prefix, it works fine and gets objects of the subclass (the cabin type).
Maybe this helps someone to locate the bug. -
10. Re: Type Substitution doesn't work with Schema2Java Client a
mstine Sep 14, 2007 4:16 PM (in response to m_schumpa)I'm having the exact same problem. The WSDL is correct, the generated classes look correct, but I'm only getting instances of the parent class. No type substitution.
I'd send code and test cases but I'm working w/ a large enterprise system that would take you forever to get setup just to test with.
Please help with this one.
Thanks! -
11. Re: Type Substitution doesn't work with Schema2Java Client a
mrokka123 Sep 24, 2007 1:50 AM (in response to m_schumpa)I'm also having the same problem. I'm using jboss4.2.0+jbossWS2.0.1+jdk1.5
everything is fine,WSDL is ok & client is also calling the service but instead of returning the subclass reference
it always returns base class object.
I also have tried using @XmlSeeAlso but same problem.
Any Suggestion to solve my problem. -
12. Re: Type Substitution doesn't work with Schema2Java Client a
richard_opalka Oct 3, 2007 10:34 AM (in response to m_schumpa)"M_schumpa" wrote:
Do you think there is a quick fix for this problem?
I'm asking because I'm writing a diploma thesis about Web Services and the deadline is the end of september.
I hope it's still not too late what about your diploma deadline. I've resolved your issue:
http://jira.jboss.org/jira/browse/JBWS-1795
Richard -
13. Re: Type Substitution doesn't work with Schema2Java Client a
richard_opalka Oct 3, 2007 10:37 AM (in response to m_schumpa)"mrokka123" wrote:
I'm also having the same problem. I'm using jboss4.2.0+jbossWS2.0.1+jdk1.5
everything is fine,WSDL is ok & client is also calling the service but instead of returning the subclass reference
it always returns base class object.
I also have tried using @XmlSeeAlso but same problem.
Any Suggestion to solve my problem.
You have to provide package-info.class file(s) to your application. Take a look to:
http://jira.jboss.org/jira/browse/JBWS-1795
Richard -
14. Re: Type Substitution doesn't work with Schema2Java Client a
mrokka123 Oct 4, 2007 5:33 AM (in response to m_schumpa)WOW! It really works. Thanks a lot Richard.
It even works on JBossWs 1.2.1 [I think Which was default JBossWs for JBoss4.2.0].
Here?s the working version:
POJO Class
A.java
package com.d2.client;
public abstract class A implements java.io.Serializable{
private String name;
public void setName(String name){
this.name=name;
}
public String getName(){
return name;
}
}
B.java
package com.d2.client;
public class B extends A implements java.io.Serializable{
}
package-info.java //this class does the magic
@javax.xml.bind.annotation.XmlSchema(namespace = "http://client.d2.com/")
package com.d2.client;
-------------------------------------------------------------------------------------
WebService
package com.d2.webservice;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.soap.SOAPBinding;
import com.d2.client.*;
@WebService(name = "MyWebServicePortType", serviceName = "MyWebService",
portName = "MyWebServicePort",targetNamespace = "http://client.d2.com")
@SOAPBinding(style = SOAPBinding.Style.DOCUMENT,
use = SOAPBinding.Use.LITERAL,
parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
public class MyWebService{
@WebMethod
public String getClassName(A obj){
System.out.println("class name:"+obj.getClass().getName());
System.out.println("Parent name:"+obj.getName());
return obj.getClass().getName();
}
@WebMethod
public void dummyMethod(B obj)//if we use @XmlSeeAlso then this method not needed
{
}
}
Regards,