Web services Apache CFX模式验证-契约优先

Web services Apache CFX模式验证-契约优先,web-services,validation,schema,cxf,contract-first,Web Services,Validation,Schema,Cxf,Contract First,我正在使用ApacheCXF和契约优先方法开发一个Web服务,并进行模式验证。问题是,验证不起作用。没有错误,所以它好像没有被激活。但是验证 所以,我看了一下您可以找到的官方ApacheCXF示例 我查看了这个示例并对其进行了修改,添加了模式验证和WSDL中的一些限制: <!-- HTTP Endpoint --> <jaxws:endpoint xmlns:customer="http://customerservice.example.com/" id="Custo

我正在使用ApacheCXF和契约优先方法开发一个Web服务,并进行模式验证。问题是,验证不起作用。没有错误,所以它好像没有被激活。但是验证

所以,我看了一下您可以找到的官方ApacheCXF示例

我查看了这个示例并对其进行了修改,添加了模式验证和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>

令我惊讶的是,它也不起作用

好的,我看了一个示例,其中根据README.txt文件,它还显示了如何使用CXF配置来启用模式验证


对于这个例子,模式验证是有效的。两个示例之间的区别在于,第二个示例使用JAX-WSAPI和XMLBeans方法。这有什么关系吗?为什么第一个示例中的模式验证不起作用?可能我遗漏了一些东西。

对于服务端的验证,可能需要在jaxws:endpoint上设置wsdlLocation属性,以便加载WSDL(该属性将包含模式)。目前,该示例中的验证仅在客户端进行。如果运行该服务,日志将显示:

INFO: Creating Service {http://server.customerservice.example.com/}CustomerServiceImplService from class com.example.customerservice.CustomerService
这表明它根本没有使用WSDL。

谢谢Daniel。运行Jetty(从cxfservlet.xml进行配置)并添加wsdlLocation属性,它就可以工作了。但是,我无法使它与默认服务器配置(mvn-Pserver)一起工作。我应该编辑哪个配置文件?cxf.xml?不起作用