I resolved the problem.
In fact I have three classes Person, Student and Service.
WIth Service is defined as:
import javax.xml.bind.annotation.XmlSeeAlso;
@XmlSeeAlso({Student.class})
public class Service{
public String print(Person p){
return p.info();
}
}
I used J2EE to publish the service class by creating a new web service project.
The platform generates automatically a new end point class:
package server;
import javax.jws.WebService;
@WebService(name = "ServiceEndPoint", targetNamespace = "http://server/")
public interface ServiceEndPoint {
public String Print(person p);
}
and the Service class is updated with "extends ServiceEndPoint".
But the generated WSDL file didn't take in consideration the inheritance
between person and student.
Actually, I putted the annotation in the PrintEndPoint class by creating a new
dynamic web project
with the four classes: ServiceEndPoint, Service, Person and Student. Then I
create again a new web service
project by selecting the annotated ServiceEndPoint as an End Point for my
service instead of generating a default one.
Now I have the right WSDL with an XSD schema where appear the two types person
and student with student extends person.
--------------------------------------------------
<?xml version="1.0" encoding="utf-8"?><xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://server/" elementFormDefault="unqualified"
targetNamespace="http://server/" version="1.0">
<xs:element name="print" type="tns:print"/>
<xs:element name="printResponse" type="tns:printResponse"/>
<xs:complexType name="print">
<xs:sequence>
<xs:element minOccurs="0" name="arg0" type="tns:person"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="person">
<xs:sequence>
<xs:element minOccurs="0" name="name" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="printResponse">
<xs:sequence>
<xs:element minOccurs="0" name="return" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="student">
<xs:complexContent>
<xs:extension base="tns:person">
<xs:sequence>
<xs:element minOccurs="0" name="school" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
-------------------------------------------------------
I realized that it is sufficient to put this annotation only in the
ServiceEndPoint class without repeating
it in Service and/or in Person classes.
Thank you very much for your helps.
Diana
On 8 juin 2012, at 16:20, Daniel Kulp wrote:
>
> If you throw together a quick maven build with your service/person/student
> classes, we could likely take a quick look a bit easier. Mostly just need
> the service to startup as we can likely look at the wsdl to see if it will
> work or not.
>
> Dan
>
>
> On Friday, June 08, 2012 12:28:41 PM Diana ALLAM wrote:
>> Hi,
>>
>> I am using Eclipse J2EE which generate automatically the following wsdl
>> and xsd files (by using the annotation @XmlSeeAlso):
>>
>> Here is my XSD file:
>> <?xml version="1.0" encoding="utf-8"?><xs:schema
>> xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://server/"
>> elementFormDefault="unqualified" targetNamespace="http://server/"
>> version="1.0"> <xs:element name="print" type="tns:print"/>
>> <xs:element name="printResponse" type="tns:printResponse"/>
>> <xs:complexType name="print">
>> <xs:sequence>
>> <xs:element minOccurs="0" name="arg0" type="tns:person"/>
>> </xs:sequence>
>> </xs:complexType>
>> <xs:complexType name="person">
>> <xs:sequence>
>> <xs:element minOccurs="0" name="name" type="xs:string"/>
>> </xs:sequence>
>> </xs:complexType>
>> <xs:complexType name="printResponse">
>> <xs:sequence>
>> <xs:element minOccurs="0" name="return" type="xs:string"/>
>> </xs:sequence>
>> </xs:complexType>
>> </xs:schema>
>>
>>
>> and here is my WSDL file
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <wsdl:definitions name="ServiceService" targetNamespace="http://server/"
>> xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://server/"
>> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>> xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"> <wsdl:types>
>> <schema xmlns="http://www.w3.org/2001/XMLSchema">
>> <import namespace="http://server/" schemaLocation="service_schema1.xsd"/>
>> </schema>
>> </wsdl:types>
>> <wsdl:message name="print">
>> <wsdl:part name="parameters" element="tns:print">
>> </wsdl:part>
>> </wsdl:message>
>> <wsdl:message name="printResponse">
>> <wsdl:part name="parameters" element="tns:printResponse">
>> </wsdl:part>
>> </wsdl:message>
>> <wsdl:portType name="printEndPoint">
>> <wsdl:operation name="print">
>> <wsdl:input name="print" message="tns:print">
>> </wsdl:input>
>> <wsdl:output name="printResponse" message="tns:printResponse">
>> </wsdl:output>
>> </wsdl:operation>
>> </wsdl:portType>
>> <wsdl:binding name="ServiceServiceSoapBinding" type="tns:printEndPoint">
>> <soap:binding style="document"
>> transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation
>> name="print">
>> <soap:operation soapAction="" style="document"/>
>> <wsdl:input name="print">
>> <soap:body use="literal"/>
>> </wsdl:input>
>> <wsdl:output name="printResponse">
>> <soap:body use="literal"/>
>> </wsdl:output>
>> </wsdl:operation>
>> </wsdl:binding>
>> <wsdl:service name="ServiceService">
>> <wsdl:port name="ServicePort" binding="tns:ServiceServiceSoapBinding">
>> <soap:address location="http://localhost:8081/zw/services/ServicePort"/>
>> </wsdl:port>
>> </wsdl:service>
>> </wsdl:definitions>
>>
>
> --
> Daniel Kulp
> [email protected] - http://dankulp.com/blog
> Talend Community Coder - http://coders.talend.com
>