• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Handling non numeric argument

 
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you say you send a String to the web service, you mean you send characters and not digits?
 
Ranch Hand
Posts: 282
Eclipse IDE PHP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic