1

I'm creating a code-first soap webservice, and would like to limit the input parameter to a maxmimum length. So that if someone uses the exposed wsdl to auto-generate client classes, he will see that the length is limited.

Is that possible without manually modifying the xsd?

@WebMethod
@WebResult(name = "version")
public String version(@WebParam(name = "version") String value) { //TODO limit to 10 chars
    return value;
}

So I'd like to configure the parameter in a way that the xsd outcome is as follows:

   <xs:restriction base="xs:string">
      <xs:maxLength value = "10"/>
    </xs:restriction>
membersound
  • 81,582
  • 193
  • 585
  • 1,120
  • once a client connects, check the length of the input for parameters. I don't see how hard it can be... – nafas Jul 21 '14 at 12:22
  • I mean, when the client takes the wsdl and auto-generates his classes, he should already see that the length is restricted. So I'm looking for a JAXB-way to restrict them, so that this is translated to the wsdl – membersound Jul 21 '14 at 13:06
  • Instead of using a string why not use a char array perhaps? I cant seem to find any annotation that you can use to tune the length of a input parameter. The other solution is to check the incoming string length and then return a error status to the caller. – Namphibian Jul 21 '14 at 22:05
  • I know how to validate string length and user input after I received it, that's not the problem. – membersound Jul 22 '14 at 06:08

0 Answers0