2

I need to define a Jax-RPC Web Service, with a parameter with a max length.

    @SOAPBinding(style = Style.RPC)
    public interface MessageService {

            public String sendMessage(@WebParam(partName = "id") String id,
        @WebParam(partName = "name") String name,
        @WebParam(partName = "mesg") String mesg);

Where id must be 8 characters. How can I define this constraint in Jax-RPC annotation or with configuration?

g.annunziata
  • 3,118
  • 1
  • 24
  • 25
  • 1
    http://stackoverflow.com/a/7276392/785663 says you can't do this (and links to the [@WebParam API](http://docs.oracle.com/javaee/5/api/javax/jws/WebParam.html), but http://stackoverflow.com/a/7282020/785663 has something to say about parameter verification. Not posting this as an answer as I'm still getting to grips with JAX-WS myself. – mabi Mar 19 '13 at 13:41

1 Answers1

0

Can you describe a little bit more what are you trying to do? why it is not enough to verify length after you received / before sent the id?

May be you can try to use object of your type instead of String, and run verification on it? Also, you can try to play with binding file - you can generate your Datatype converter, and try something like this:

    <jaxb:bindings version="2.1"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
   <jaxb:globalBindings generateElementProperty="false" >
               <jaxb:javaType
                    name="java.util.Calendar"
                    xmlType="xs:dateTime"
                    parseMethod="javax.xml.bind.DatatypeConverter.parseDateTime"
                    printMethod="javax.xml.bind.DatatypeConverter.printDateTime" />
        </jaxb:globalBindings>
</jaxb:bindings>
evgenyl
  • 7,837
  • 2
  • 27
  • 32