JAX-WS and XSD Validation

扶醉桌前 提交于 2019-12-20 04:50:21

问题


I have a wsdl that has a imported xsd, this xsd has quite a restrictions like this:

<xsd:simpleType name="len_type">
    <xsd:restriction base="xsd:string">
        <xsd:pattern value='[:alnum:]{4} [\d]{2} [\d] [\d]{2}' />
    </xsd:restriction>
</xsd:simpleType>

So I would thind that when I deploy this ear to glassfish via netbeans that there would be validation done on the data that is passed in, but this is not the case. Is there any calls I need to make to ensure that the data is validated before it is passed to my @WebService object and turned into a Java object.


回答1:


Use the SchemaValidation annotation.

Be forewarned, that it works only for web services of document/literal style. And be careful about schema validation, if you are using XSD imports.



来源:https://stackoverflow.com/questions/1380714/jax-ws-and-xsd-validation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!