Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Handling non numeric argument

 
Kevin Eddy
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you say you send a String to the web service, you mean you send characters and not digits?
 
Michael Angstadt
Ranch Hand
Posts: 277
Eclipse IDE Java PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Dan Drillich
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kevin,

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

Regards,
Dan
 
Kevin Eddy
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic