Skip to main content

@SchemaValidation and exceptions

6 replies [Last post]
kaumar
Offline
Joined: 2007-09-18

Hi,

I have noticed that in schema validation the exceptions are not consistent in different scenarios.
E.g. If the client sends an invalid request schema validation throws a WebServiceException. But when the service sends an invalid response schema validation throws a SOAPFaultException. I would expect to receive a SOAP Fault in both cases.

Another issue with the schema validation exceptions is that the "stack trace" is partly included. E.g.
[java] javax.xml.ws.soap.SOAPFaultException: javax.xml.bind.MarshalException
[java] - with linked exception:
[java] [org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'MsgId'. One of '{"http://xxxx":RequestId}' is expected.]

I would prefer to see only the validation error message in the SOAP Fault (without any mention to javax.xml.bind.MarshalException and org.xml.sax.SAXParseException).

regards
Martti

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kaumar
Offline
Joined: 2007-09-18

I guess the appropriate solution to my second issue is to use Validation error handlers on both endpoints. This way the contents of the exception can be manipulated.

However when the client sends an invalid request the schema validation still throws a WebServiceException. Does this mean that the validation takes already place at the client side message handler?

regards
Martti

jitu
Offline
Joined: 2003-06-14

Are you creating client proxy with SchemaValidationFeature ? If you are not, there is no client side schema validation done.

kaumar
Offline
Joined: 2007-09-18

Yes, I'm using SchemaValidationFeature at the client side. Is this supposed to validate incoming or outgoing messages?

jitu
Offline
Joined: 2003-06-14

Both the incoming and outgoing on the client side.

kaumar
Offline
Joined: 2007-09-18

Ok, now I think I understand what is going on here. When both client and service side schema validation is used, the invalid request is blocked already at the client side and a WebServiceException is thrown. If I leave out the client side schema validation the service blocks the invalid request and throws a SOAPFaultException. Guess I have to live with that.

Thanks!
Martti

elevior
Offline
Joined: 2008-04-23

Hi, I have the same problem in my code. If I use schemaValidation in the client and service, WebServiceException is thrown. If i don't use schemaValidation in the client, SoapFaultException is thrown.

I was thinking that this one was not the correct behavior, because i wanted to take my own exception.

Is it a correct behavior that a WebServiceException throws?

Thanks