Java 如何使用SpringWeb服务捕获所有必需的已归档错误消息';s自定义验证拦截器
在SpringWS2.0.0中,对于Java 如何使用SpringWeb服务捕获所有必需的已归档错误消息';s自定义验证拦截器,java,xml,spring,validation,xsd,Java,Xml,Spring,Validation,Xsd,在SpringWS2.0.0中,对于PayLoadValidatingInterceptorByValidation my xsd请求文件,当发现验证错误时,只显示一条必填字段错误消息。 我想得到的是xsd模式文件中(nillable=false)的所有必需字段错误消息 <xs:element name="firstname" nillibale="false" type="xs:string"/> <xs:element name="middlename" nillibale
PayLoadValidatingInterceptor
ByValidation my xsd请求文件,当发现验证错误时,只显示一条必填字段错误消息。
我想得到的是xsd模式文件中(nillable=false
)的所有必需字段错误消息
<xs:element name="firstname" nillibale="false" type="xs:string"/>
<xs:element name="middlename" nillibale="false" type="xs:string"/>
<xs:element name="lastname" nillibale="false" type="xs:string"/>
在我的Customer.xsd架构文件中
<xs:element name="firstname" nillibale="false" type="xs:string"/>
<xs:element name="middlename" nillibale="false" type="xs:string"/>
<xs:element name="lastname" nillibale="false" type="xs:string"/>
注意:没有使用日志记录,我使用SoapUI工具进行测试
而且,输出是
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Client</faultcode>
<faultstring xml:lang="en">Validation error</faultstring>
<detail>
<spring-ws:ValidationError xmlns:spring-ws="springframework.org/spring-ws">cvc-complex-type.2.4.b: The content of element 'cus:customer' is not complete. One of '{"customer.model.web.insurance.ace.org":firstname'; is expected.</spring-ws:ValidationError>
</detail>
</SOAP-ENV:Fault>
SOAP-ENV:客户端
验证错误
cvc复杂类型。2.4.b:元素“cus:customer”的内容不完整。应为“{”customer.model.web.insurance.ace.org”之一:firstname。
在我看来,我想得到的是
<SOAP-ENV:Fault>
<faultcode>SOAP-ENV:Client</faultcode>
<faultstring xml:lang="en">Validation error</faultstring>
<detail>
<spring-ws:ValidationError xmlns:spring-ws="springframework.org/spring-ws">cvc-complex-type.2.4.b: The content of element 'cus:customer' is not complete. One of '{"customer.model.web.insurance.ace.org":firstname'; is expected.</spring-ws:ValidationError>
<spring-ws:ValidationError xmlns:spring-ws="springframework.org/spring-ws">cvc-complex-type.2.4.b: The content of element 'cus:customer' is not complete. One of '{"customer.model.web.insurance.ace.org":middlename'; is expected.</spring-ws:ValidationError>
<spring-ws:ValidationError xmlns:spring-ws="springframework.org/spring-ws">cvc-complex-type.2.4.b: The content of element 'cus:customer' is not complete. One of '{"customer.model.web.insurance.ace.org":lastname'; is expected.</spring-ws:ValidationError>
</detail>
</SOAP-ENV:Fault>
SOAP-ENV:客户端
验证错误
cvc complex type.2.4.b:元素“cus:customer”的内容不完整。应为“{”customer.model.web.insurance.ace.org”中的一个“{”firstname“。
cvc complex type.2.4.b:元素“cus:customer”的内容不完整。应为“{”customer.model.web.insurance.ace.org”中的一个“{”middlename“。
cvc complex type.2.4.b:元素“cus:customer”的内容不完整。应为“{”customer.model.web.insurance.ace.org”:lastname;之一。
AFAIK验证程序返回所有无效字段,您如何处理此异常/错误/故障取决于您(以及您如何定义架构/响应等)。在YOUR日志中,所有错误都应显示(它们记录在警告级别).SOAP-ENV:我使用PayloadValidationInterceptor验证了客户端验证错误,但它只能显示“firstname”的一个错误代码。它无法显示所有“firstname”、“middlename”和“lastname”的错误代码。您认为我需要编写自定义验证侦听器吗?请将输出添加到您的初始帖子不是作为评论。如前所述,请检查您的日志以查看是否所有验证错误都可用(应该在警告时记录,我假设您有一些日志设置)。另外,您使用的是哪个版本的Spring WS?请添加一些配置以查看您是如何设置的。