XFire

Schema validation in JAXB does not return validation errors to the client #2

Details

  • Type: Improvement Improvement
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.2.4
  • Fix Version/s: 1.2.5
  • Component/s: JAXB 2.0
  • Labels:
    None
  • Number of attachments :
    3

Description

Hi,

this Issue should be a reopen for XFIRE-771. Perhaps there has happend a mistake when checking in the fix for that one?
Because I get the same problem as described there in version 1.2.4:
Instead of information about the nested validation Exception there appears only the "Unmarshal" Exception at the client side when a validation error occurs:
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>Could not unmarshall type.</faultstring>
</soap:Fault>

I'd also prefer to see something like this instead, so that the caller can react himself:
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'width'. One of '{"":length}' is expected.</faultstring>
</soap:Fault>

Could you please check what went wrong?

Thanks,
Frank

  1. services.xml
    28/Feb/07 3:16 AM
    0.7 kB
    Frank Grupe
  2. TestWebService.java
    28/Feb/07 3:16 AM
    0.4 kB
    Frank Grupe
  3. TestWebService.xsd
    28/Feb/07 3:15 AM
    0.4 kB
    Frank Grupe

Activity

Hide
Tomasz Sztelak added a comment -

Can you provide simple test ( with schema') or junit to reproduce this problem ?

Show
Tomasz Sztelak added a comment - Can you provide simple test ( with schema') or junit to reproduce this problem ?
Hide
Frank Grupe added a comment -

Hi Tomasz,

I don't have an XFire build environment, just working with the binaries, so I have attached a simple testcase containing the XSD for JAXB generation, the services.xml with the validation enabled and a simple WebService implementation.
I have tested the WebService with the Eclipse build-in WebService Explorer and when I pass an invalid SOAP Message e.g. with a missing parameter like:

<?xml version="1.0" encoding="UTF-8" ?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:q0="http://www.test.de" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<q0:Test />
</soapenv:Body>
</soapenv:Envelope>

The service returns a fault missing the actual validation Exeption:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>Could not unmarshall type.</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>

Whereas I would expect something like this, which I only see in the server log. But the client side should see this detailed fault message to be able to correct it I think:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>Could not unmarshall type.: org.xml.sax.SAXParseException: cvc-complex-type.2.4.b: The content of element 'q0:Test' is not complete. One of '{"":teststring}' is expected.</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>

Show
Frank Grupe added a comment - Hi Tomasz, I don't have an XFire build environment, just working with the binaries, so I have attached a simple testcase containing the XSD for JAXB generation, the services.xml with the validation enabled and a simple WebService implementation. I have tested the WebService with the Eclipse build-in WebService Explorer and when I pass an invalid SOAP Message e.g. with a missing parameter like: <?xml version="1.0" encoding="UTF-8" ?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:q0="http://www.test.de" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <q0:Test /> </soapenv:Body> </soapenv:Envelope> The service returns a fault missing the actual validation Exeption: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soap:Body> <soap:Fault> <faultcode>soap:Server</faultcode> <faultstring>Could not unmarshall type.</faultstring> </soap:Fault> </soap:Body> </soap:Envelope> Whereas I would expect something like this, which I only see in the server log. But the client side should see this detailed fault message to be able to correct it I think: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soap:Body> <soap:Fault> <faultcode>soap:Server</faultcode> <faultstring>Could not unmarshall type.: org.xml.sax.SAXParseException: cvc-complex-type.2.4.b: The content of element 'q0:Test' is not complete. One of '{"":teststring}' is expected.</faultstring> </soap:Fault> </soap:Body> </soap:Envelope>
Hide
Tomasz Sztelak added a comment -

Fixed in svn

Show
Tomasz Sztelak added a comment - Fixed in svn
Hide
Paul King added a comment -

I know this is a little old, but just wondering why faultcode here is soap:Server not soap:Client. Surely, if the incoming request is not valid, it is an error the client has made?

Show
Paul King added a comment - I know this is a little old, but just wondering why faultcode here is soap:Server not soap:Client. Surely, if the incoming request is not valid, it is an error the client has made?

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: