Apache camel 在Camel路由内的CXF SOAP端点中启用XML验证
我正在JBossFuse内部开发一个代码优先的SOAP服务。我用输入和输出类定义了一个接口Apache camel 在Camel路由内的CXF SOAP端点中启用XML验证,apache-camel,cxf,jbossfuse,Apache Camel,Cxf,Jbossfuse,我正在JBossFuse内部开发一个代码优先的SOAP服务。我用输入和输出类定义了一个接口my.endpoint.interface。wsdl生成得很好,服务正在工作。端点由调用我的驼峰路由的CXF处理 版本: JBoss保险丝6.2.1 Apache Camel 2.15.1 Apache CXF 3.0.4 这是我的捆绑包的配置: <blueprint> <cxf:cxfEndpoint id="myEndpoint" address="/my/
my.endpoint.interface
。wsdl生成得很好,服务正在工作。端点由调用我的驼峰路由的CXF处理
版本:JBoss保险丝6.2.1
Apache Camel 2.15.1
Apache CXF 3.0.4 这是我的捆绑包的配置:
<blueprint>
<cxf:cxfEndpoint id="myEndpoint"
address="/my/"
serviceClass="my.endpoint.Interface">
</cxf:cxfEndpoint>
<camelContext>
<route>
<from uri="cxf:bean:myEndpoint" />
<to uri="bean:doProcess" />
</route>
</camelContext>
</blueprint>
在blueprint文件中配置
cxfEndpoint
,会在运行时引发异常
<cxf:cxfEndpoint id="readingsEndpoint"
address="/readings/"
serviceClass="my.endpoint.Interface">
<cxf:schemaLocations>
<schemaLocation>classpath:my/endpoint/schema1.xsd</schemaLocation>
</cxf:schemaLocations>
</cxf:cxfEndpoint>
如果您的XSD与WSDL分离,即不同的文件,那么您可以使用验证器组件
<camelContext>
<route>
<from uri="cxf:bean:myEndpoint" />
<to uri="validator:my/endpoint/schema1.xsd" />
<to uri="bean:doProcess" />
</route>
</camelContext>
您可能还应该使用doTry/doCatch将其括起来,或者在路由或上下文中添加一个错误处理程序
要将cxf端点配置为将Exchange主体设置为实际的soap:body,可以执行以下操作:
<cxf:cxfEndpoint id="readingsEndpoint"
address="/readings/"
serviceClass="my.endpoint.Interface">
<cxf:properties>
<entry key="dataFormat" value="PAYLOAD"/>
</cxf:properties>
</cxf:cxfEndpoint>
在我的合同第一次设置中,我在蓝图上下文中启用模式验证,如下所示:
<cxf:cxfEndpoint id="cxfEndpoint" address="http://0.0.0.0:${cxf.port}/${application-path}" serviceClass="my.generated.service.Class" >
<cxf:properties>
<entry key="schema-validation-enabled" value="true" />
</cxf:properties>
</cxf:cxfEndpoint>
这应该首先适用于代码。此时,交换主体已经被解封到POJO。是否有一些配置告诉CXF不要解组,并在验证后自己执行?我明白了。是的,您可以将dataFormat属性设置为“PAYLOAD”,我将更新我的答案。
<cxf:cxfEndpoint id="readingsEndpoint"
address="/readings/"
serviceClass="my.endpoint.Interface">
<cxf:properties>
<entry key="dataFormat" value="PAYLOAD"/>
</cxf:properties>
</cxf:cxfEndpoint>
<cxf:cxfEndpoint id="cxfEndpoint" address="http://0.0.0.0:${cxf.port}/${application-path}" serviceClass="my.generated.service.Class" >
<cxf:properties>
<entry key="schema-validation-enabled" value="true" />
</cxf:properties>
</cxf:cxfEndpoint>