File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes Handling non numeric argument Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Handling non numeric argument" Watch "Handling non numeric argument" New topic
Author

Handling non numeric argument

Kevin Eddy
Ranch Hand

Joined: Feb 24, 2010
Posts: 74
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.
Jim Akmer
Ranch Hand

Joined: Jul 06, 2010
Posts: 104
When you say you send a String to the web service, you mean you send characters and not digits?
Michael Angstadt
Ranch Hand

Joined: Jun 17, 2009
Posts: 274

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.


SCJP 6 || SCWCD 5
Dan Drillich
Ranch Hand

Joined: Jul 09, 2001
Posts: 1180
Kevin,

4.2. Schema Validation explains the subject. I guess it's not enabled by default, due to performance considerations.

Regards,
Dan

William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
Kevin Eddy
Ranch Hand

Joined: Feb 24, 2010
Posts: 74
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Handling non numeric argument