3

我在尝试验证在 JBoss AS (v. 5.1.0) 上运行的服务的传入肥皂消息时遇到了一些困难。

在我的代码中,我明确设置了一些必填字段,例如:

public class MyClass {
    @XmlElement(required=true, nillable=false)
    private List<myOtherObjects> myList;
}

此要求也反映在 WSDL 中(注意缺少 minOccurs="0"):

<xs:element maxOccurs="unbounded" name="myList" type="tns:myOtherObjects" /> 

但是,当我执行将 myList 设置为空或 null 的测试 soap 消息时,这些限制将被完全忽略,迫使我在服务的应用程序逻辑中手动验证。

我在网上搜索了一下,发现在WebLogic上,默认情况下似乎没有启用验证,不过可以通过修改weblogic-webservices.xml文件来开启它。( http://forums.oracle.com/forums/thread.jspa?threadID=783972&tstart=115 )

我想知道在肥皂消息到达服务之前是否有与 JBoss AS 类似的事情来启用自动验证。任何帮助将不胜感激。

奥利弗

4

1 回答 1

0

在您的端口类型上:

@SchemaValidation(handler = YourSchemaValidationErrorHandler.class)
@WebService
@Stateless
public class ......... {

}
于 2011-11-21T14:22:27.830 回答