简体   繁体   English

Apache CFX Schema验证-首先签订合同

[英]Apache CFX Schema validation - contract first

I am developing a Web service using Apache CXF and contract first approach with schema validation. 我正在使用Apache CXF开发Web服务,并采用具有模式验证的契约优先方法。 Problem is, that validation is not working. 问题是,验证不起作用。 There is no error, so it like is not activated. 没有错误,因此未激活。 But validation is configured . 但是验证已配置

So, I have took a look to official Apache CXF examples you can find here . 因此,我看了一下可以在此处找到的官方Apache CXF示例。

I took a look to wsdl_first example and modify it adding schema validation and some restriction in WSDL: 我看了一下wsdl_first示例,并对其进行了修改,添加了模式验证和WSDL中的一些限制:

<!-- HTTP Endpoint -->
<jaxws:endpoint xmlns:customer="http://customerservice.example.com/"
    id="CustomerServiceHTTP" address="http://localhost:9090/CustomerServicePort"
    serviceName="customer:CustomerServiceService" endpointName="customer:CustomerServiceEndpoint"
    implementor="com.example.customerservice.server.CustomerServiceImpl">

    <jaxws:features>
        <bean class="org.apache.cxf.feature.LoggingFeature" />
    </jaxws:features>
            <!-- schema validation-->
    <jaxws:properties>
        <entry key="schema-validation-enabled" value="true" />
    </jaxws:properties>
</jaxws:endpoint>

To my surprise, it doesn't work either. 令我惊讶的是,它也不起作用。

OK, so I took a look to wsdl_first_xmlbeans example, where according with the README.txt file, it also shows how CXF configuration can be used to enable schema validation . 好的,让我看一下wsdl_first_xmlbeans示例,其中根据README.txt文件, 还显示了如何使用CXF配置来启用模式验证

And for this example, schema validation works. 对于此示例,架构验证有效。 The difference between both examples is that the second one use JAX-WS APIs and with the XMLBeans approach. 两个示例之间的区别在于,第二个示例使用JAX-WS API和XMLBeans方法。 Does it have something to do? 它有事要做吗? Why schema validation is not working for first example? 为什么模式验证不适用于第一个示例? Probably, I am missing something. 可能是我遗漏了一些东西。

For validation on the service side, it would likely need to have a wsdlLocation attribute set on the jaxws:endpoint so it would load the WSDL (that would then contain the schemas). 为了在服务端进行验证,可能需要在jaxws:endpoint上设置wsdlLocation属性,以便它将加载WSDL(然后将包含模式)。 Currently, the validation in that example is on the client side only. 当前,该示例中的验证仅在客户端进行。 If you run the service, the log shows: 如果运行该服务,日志将显示:

INFO: Creating Service {http://server.customerservice.example.com/}CustomerServiceImplService from class com.example.customerservice.CustomerService

which shows it's not using the WSDL at all. 这表明它根本没有使用WSDL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM