使用JAXB进行JAX-WS请求验证 [英] JAX-WS request validation using JAXB

查看:120
本文介绍了使用JAXB进行JAX-WS请求验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在JAX-WS中,要验证传入的请求,其中一种方法是使用@SchemaValidation,如下面的链接所示。

In JAX-WS, to validate the incoming request, one of the ways is to use @SchemaValidation as suggested in below link.

JAX-WS和XSD验证

然而应用程序我正在使用的服务器(WAS 7)尚不支持@SchemaValidation。 (如果WAS 7确实支持此注释,请纠正我)

However the application server (WAS 7) I am using does not yet support @SchemaValidation. (Please correct me if WAS 7 does support this annotation)

所以我正在寻找其他选项,例如实现处理程序来验证传入请求。无论是在处理程序还是端点类本身,我都可以创建JAXBContext并使用JAXB验证器。我是否需要显式创建JAXBContext,或者它是否可用作资源/注释,因为JAX-WS内部使用JAXB?
这是在JAX-WS中实现验证的好方法吗? (在没有@SchemaValidation验证的情况下)

So I am looking at other options like implementing a handler to validate the incoming request. Either in the handler or the endpoint class itself, I can create the JAXBContext and use the JAXB validator. Do I need to create the JAXBContext explicitly or is it available as a resource / annotation since JAX-WS internally uses JAXB? Is this a good way to implement validation in JAX-WS? (In the absence of @SchemaValidation validation)

在Web服务中验证传入请求xml是标准做法还是由于性能受到影响而被忽略拿?

Is it a standard practice to validate the incoming request xml in web services or is it given a skip due to performance hit it might take?

推荐答案

如同每个MVC系统一样,验证传入请求xml是一个好习惯。 (MVC可能不适合这里,但原则上,它只是视图是XML)。如果不支持上面提到的注释( @SchemaValidation ),那么一种方法是使用handler,它将使用 JAXB验证

It is a good practice to validate the incoming request xml as is the case with every MVC system. (MVC might not fit here but in principle, its same just that the view is XML). If the mentioned annotation (@SchemaValidation) is not supported, then one way out is is use handler which will validate the incoming request using JAXB Validation.

这篇关于使用JAXB进行JAX-WS请求验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆