I'm writing a jax-ws document literal soap service. I have an int as an argument. I'm have a client that I test it with. I create a HttpURLConnection and basically pump a file with a soap message to the service. This method I'm invoking takes an int as a parameter. So naturally, I sent a String over and to my surprise, jax-ws converts the String to an int with zero as the value. Id rather throw an exception. I'm not exactly sure how to go about this. I do have a soap handler on my service which dumps soap messages to an error log. Any advice as to how to return an error when the value passed is non numeric? I could just change the argument to a string and manually check once my web method begins to execute but that doesn't seem like the correct way to do this.
Does the web service use RPC style? If so, using Document style instead might help. Document style web services add an XML schema to the WSDL, which specifically defines how the SOAP body should look. So if the request's SOAP body contains a string where there should be an integer, I think that this might cause an error to be thrown.
4.2. Schema Validation explains the subject. I guess it's not enabled by default, due to performance considerations.
William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
Joined: Feb 24, 2010
thanks for your replies. I was able to build a validationErrorHandler and then put then error on the on the MessageContext and check for it in my service.
Super article on that here: http://java.sys-con.com/node/952429