【问题标题】:Performing schema validation on incoming SOAP messages in WebSphere在 WebSphere 中对传入的 SOAP 消息执行模式验证
【发布时间】:2012-11-20 16:33:45
【问题描述】:

我有一些网络服务,我想对传入的消息进行架构验证。根据我的研究,我发现有一个注解 @SchemaValidation,但它只在 Oracle 的 JBoss 上可用(也可能在 WebLogic 和 Glassfish 上?)而不是 WebSphere。

对于 WebSphere,我能想到的唯一解决方案是编写一个自定义 SOAP 处理程序并在那里验证传入的 XML,但问题是我不知道如何将验证错误传递给我的 Web 服务实现类,以便我可以返回包含客户端错误的故障。

有没有更好的方法在 WebSphere(第 7 版)上验证 SOAP 消息?

【问题讨论】:

标签: java web-services soap websphere


【解决方案1】:

啊哈...我不得不从自定义 SOAPHandler 中抛出一个 SOAPFaultException,如下所示:

try
{
    ...
    ...
    validator.validate(source); 
}
catch (SAXException saxe)
{
    System.out.println("SAXException occurred");
    SOAPFault fault = null;
    try
    {
        fault = SOAPFactory.newInstance().createFault();
        fault.setFaultString(saxe.getMessage());
    }
    catch (SOAPException soape)
    {
        LOG.error("Error creating SOAPFault: "+soape.getMessage());
    }
    throw new SOAPFaultException(fault);
}

SOAPFaultException 被发回调用客户端,他们可以看到他们的消息导致的验证错误。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多