CXF 2.2.12: How to turn off schema validation on the client side

心已入冬 提交于 2019-12-21 08:54:56

问题


I would like to turn off schema validation for JAXB-bound messages. I am dealing with the client-side CXF code (WSDL first generation). I have tried using

<jaxws:client name="{http://apache.org/hello_world_soap_http}SoapPort"
    createdFromAPI="true">
    <jaxws:properties>
        <entry key="schema-validation-enabled" value="true" />
    </jaxws:properties>
</jaxws:client>

Without success (see reference CXF FAQ ). I've had difficulty finding a programmatic way of settings this property. I've also explored short-circuiting CXF and accessing the parser, unmarshaller, etc.

Thanks for your help.


回答1:


To turn off the schema validation you should set the schema-validation-enabled property to false.

According to documentation referred by you (CXF FAQ).

To enable schema validation (all requests and responses will be validated against schema) set

<entry key="schema-validation-enabled" value="true" />

To disable schema validation (none of the requests nor responses will be validated against schema) do nothing cause it is the default behavior or set

<entry key="schema-validation-enabled" value="false" />



回答2:


Or from the code as follows:

    Client client = ClientProxy.getClient(XYZSOAPEndPoint);
    HTTPConduit http = (HTTPConduit) client.getConduit();
    HTTPClientPolicy policy = new HTTPClientPolicy();
    policy.setAllowChunking(false);
    http.setClient(policy);
    ((BindingProvider)XYZSOAPEndPoint).getRequestContext().put("schema-validation-enabled",true);



回答3:


@SchemaValidation(type = SchemaValidation.SchemaValidationType.NONE) put this annotation to your endpoint implementation class



来源:https://stackoverflow.com/questions/7744796/cxf-2-2-12-how-to-turn-off-schema-validation-on-the-client-side

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