2 Replies Latest reply on Aug 10, 2009 2:18 PM by Matt Cheely

    Issues with @SchemaValidation and inheritance / @XmlSeeAlso

    Matt Cheely Newbie

      I am developing a web service that uses inheritance to process multiple types of payments.

      The relevant code:

      @Stateless
      @WebService( name="PaymentService",
       serviceName = "PaymentService")
      @WebContext(contextRoot="/WebServices")
      @SchemaValidation
      @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
      public class PaymentService {
      
       private static final Log log = Logging.getLog(PaymentService.class);
      
       @WebMethod
       public PaymentResponse processPayment(Payment payment) {...
      


      And

      @XmlSeeAlso({CheckPayment.class, BankTransferPayment.class, CreditCardPayment.class})
      public abstract class Payment {...
      


      The relevant parts of the WSDL:
      <xs:schema targetNamespace='http://foo.com/' version='1.0' xmlns:tns='http://foo.com/' xmlns:xs='http://www.w3.org/2001/XMLSchema'>
       <xs:element name='processPayment' nillable='true' type='tns:payment'/>
       <xs:element name='processPaymentResponse' nillable='true' type='tns:paymentResponse'/>
       <xs:complexType abstract='true' name='payment'>
       <xs:sequence>
       <xs:element minOccurs='0' name='accountNumber' type='xs:string'/>
       <xs:element name='amount' type='xs:decimal'/>
      
       <xs:element name='invoiceNumber' type='xs:string'/>
       <xs:element name='paymentDate' type='xs:dateTime'/>
       <xs:element name='receiptDate' type='xs:dateTime'/>
       <xs:element name='source' type='xs:string'/>
       <xs:element minOccurs='0' name='sourceTransactionId' type='xs:string'/>
       </xs:sequence>
       </xs:complexType>
       <xs:complexType name='checkPayment'>
       <xs:complexContent>
      
       <xs:extension base='tns:payment'>
       <xs:sequence>
       <xs:element minOccurs='0' name='accountId' type='xs:string'/>
       <xs:element minOccurs='0' name='bankId' type='xs:string'/>
       <xs:element minOccurs='0' name='checkNumber' type='xs:string'/>
       </xs:sequence>
       </xs:extension>
       </xs:complexContent>
       </xs:complexType>
      
       <xs:complexType name='bankTransferPayment'>
       <xs:complexContent>
       <xs:extension base='tns:payment'>
       <xs:sequence>
       <xs:element minOccurs='0' name='accountId' type='xs:string'/>
       <xs:element minOccurs='0' name='bankId' type='xs:string'/>
       <xs:element minOccurs='0' name='transactionId' type='xs:string'/>
       </xs:sequence>
       </xs:extension>
      
       </xs:complexContent>
       </xs:complexType>
       <xs:complexType name='creditCardPayment'>
       <xs:complexContent>
       <xs:extension base='tns:payment'>
       <xs:sequence>
       <xs:element minOccurs='0' name='creditCardType' type='xs:string'/>
       <xs:element minOccurs='0' name='reference' type='xs:string'/>
       <xs:element minOccurs='0' name='transactionId' type='xs:string'/>
      
       </xs:sequence>
       </xs:extension>
       </xs:complexContent>
       </xs:complexType>
      ...
      


      The issue I am having is that while the service works fine when schema validation is disabled, but when I enable it, and send this request:

      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://foo.com/" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
       <soapenv:Header/>
       <soapenv:Body>
       <req:processPayment xsi:type="creditCardPayment">
       <amount>1.00</amount>
       <invoiceNumber>10239659</invoiceNumber>
       <paymentDate>2009-07-24T00:00:00</paymentDate>
       <receiptDate>2009-07-27T10:52:55.1416037-04:00</receiptDate>
       <source>Magic</source>
       <sourceTransactionId>1000</sourceTransactionId>
       <creditCardType>Visa</creditCardType>
       <reference>12</reference>
       <transactionId>32</transactionId>
       </req:processPayment>
       </soapenv:Body>
      </soapenv:Envelope>
      


      I get the following error. Similar errors occur for the other payment types.

      org.jboss.ws.WSException: org.xml.sax.SAXException: cvc-elt.4.2: Cannot resolve 'creditCardPayment' to a type definition for element 'req:processPayment'.
      


      I can't see why that request XML shouldn't validate. Can anybody tell me if this is expected behavior, or if I should file a bug against it? Any ideas for a workaround?