Tuscany generates incorrect WSDL for @XmlJavaTypeAdapter
--------------------------------------------------------

                 Key: TUSCANY-3779
                 URL: https://issues.apache.org/jira/browse/TUSCANY-3779
             Project: Tuscany
          Issue Type: Bug
          Components: Java SCA Axis Binding Extension
    Affects Versions: Java-SCA-1.6
            Reporter: Simon Nash


The Tuscany runtime generates incorrect WSDL for a Java datatype that uses the 
@XmlJavaTypeAdapter annotation.

For the following Java code (available in itest/jaxws):

@Remotable
public interface TestService {
    void sendAbstract(TestAbstract data);
}

@XmlJavaTypeAdapter(TestAdapter.class)
public abstract class TestAbstract {
    public String firstName = "?";
    public String lastName = "??";
    public String greeting = "???";
    public String sender = "Anonymous";
    public String getGreeting() {
        return greeting;
    }
}

public class TestAdapter extends XmlAdapter<TestAbstractImpl, TestAbstract> {
    public TestAbstract unmarshal(TestAbstractImpl ai) throws Exception {
        TestAbstract a = 
(TestAbstract)this.getClass().getClassLoader().loadClass(ai.className).newInstance();
        a.sender = ai.someMessage;
        return a;
    }
    public TestAbstractImpl marshal(TestAbstract v) throws Exception {
        TestAbstractImpl ai = new TestAbstractImpl();
        ai.className = v.getClass().getName();
        ai.someMessage = "YouKnowWho";
        return ai;
    }
}

public class TestAbstractImpl {
    public String className;
    public String someMessage;
}

the Tuscany runtime generates the following WSDL and schema definitions:

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="TestServiceService" targetNamespace="http://jtest/"; 
xmlns:tns="http://jtest/";
      xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"; 
xmlns:xs="http://www.w3.org/2001/XMLSchema";
      xmlns:SOAP="http://schemas.xmlsoap.org/wsdl/soap/"; 
xmlns:SOAP11="http://schemas.xmlsoap.org/wsdl/soap/";>
  <wsdl:types>
    <xs:schema attributeFormDefault="qualified" elementFormDefault="unqualified"
        targetNamespace="http://jtest/"; xmlns:tns="http://jtest/"; 
xmlns:xs="http://www.w3.org/2001/XMLSchema";>
      <xs:element name="sendAbstract">
        <xs:complexType>
          <xs:sequence>
            <xs:element minOccurs="0" name="arg0" nillable="true" 
type="tns:testAbstract"/>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="sendAbstractResponse">
        <xs:complexType/>
      </xs:element>
      <xs:complexType abstract="true" name="testAbstract">
        <xs:sequence><xs:element minOccurs="0" name="firstName" 
type="xs:string"/>
          <xs:element minOccurs="0" name="lastName" type="xs:string"/>
          <xs:element minOccurs="0" name="greeting" type="xs:string"/>
          <xs:element minOccurs="0" name="sender" type="xs:string"/>
        </xs:sequence>
      </xs:complexType>
    </xs:schema>
  </wsdl:types>
  <wsdl:message name="sendAbstract">
    <wsdl:part name="sendAbstract" element="tns:sendAbstract">
    </wsdl:part>
  </wsdl:message>
  <wsdl:message name="sendAbstractResponse">
    <wsdl:part name="sendAbstractResponse" element="tns:sendAbstractResponse">
    </wsdl:part>
  </wsdl:message>
  <wsdl:portType name="TestService">
    <wsdl:operation name="sendAbstract">
      <wsdl:input message="tns:sendAbstract">
    </wsdl:input>
      <wsdl:output message="tns:sendAbstractResponse">
    </wsdl:output>
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="TestServiceBinding" type="tns:TestService">
    <SOAP:binding style="document" 
transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="sendAbstract">
      <SOAP:operation/>
      <wsdl:input>
        <SOAP:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <SOAP:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="TestServiceService">
    <wsdl:port name="TestServicePort" binding="tns:TestServiceBinding">
      <SOAP:address location="http://localhost:8081/TestService"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

This is incorrect because the service expects the data defined by 
TestAbstractImpl (className and someMessage) to be passed on the wire, not the 
data defined by TestAbstract.  Any non-Tuscany client that uses this WSDL 
generated by Tuscany wouldn't be able to interoperate with the Tuscany service.

Using JAX-WS to generate WSDL for the same Java code produces correct WSDL, as 
follows:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is 
JAX-WS RI 2.1.1 in JDK 6. -->
<definitions targetNamespace="http://jtest/"; 
xmlns="http://schemas.xmlsoap.org/wsdl/"; xmlns:tns="http://jtest/"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
  <types>
    <xsd:schema>
      <xsd:import namespace="http://jtest/"; 
schemaLocation="TestWebService_schema1.xsd"/>
    </xsd:schema>
  </types>
  <message name="sendAbstract">
    <part name="parameters" element="tns:sendAbstract"/>
  </message>
  <message name="sendAbstractResponse">
    <part name="parameters" element="tns:sendAbstractResponse"/>
  </message>
  <portType name="TestWebService">
    <operation name="sendAbstract">
      <input message="tns:sendAbstract"/>
      <output message="tns:sendAbstractResponse"/>
    </operation>
  </portType>
</definitions>

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema version="1.0" targetNamespace="http://jtest/"; 
xmlns:tns="http://jtest/"; xmlns:xs="http://www.w3.org/2001/XMLSchema";>

  <xs:element name="sendAbstract" type="tns:sendAbstract"/>

  <xs:element name="sendAbstractResponse" type="tns:sendAbstractResponse"/>

  <xs:complexType name="sendAbstract">
    <xs:sequence>
      <xs:element name="arg0" type="tns:testAbstractImpl" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="testAbstractImpl">
    <xs:sequence>
      <xs:element name="className" type="xs:string" minOccurs="0"/>
      <xs:element name="someMessage" type="xs:string" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="sendAbstractResponse">
    <xs:sequence/>
  </xs:complexType>
</xs:schema>


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to