【问题标题】:Warning message when calling a SOAP webservice调用 SOAP Web 服务时的警告消息
【发布时间】:2014-05-28 14:31:29
【问题描述】:

我在尝试调用 SOAP 网络服务时收到此警告消息

May 28, 2014 10:25:39 AM com.sun.xml.ws.transport.http.HttpAdapter fixQuotesAroundSoapAction
INFO: Received WS-I BP non-conformant Unquoted SoapAction HTTP header: /performAction

谁能告诉我怎么解决?

【问题讨论】:

    标签: web-services soap


    【解决方案1】:

    以下是导致此警告的代码,

    /**
     *
     * @param con
     * @param codec
     * @return
     * @throws IOException
     *         ExceptionHasMessage exception that contains particular fault message
     *         UnsupportedMediaException to indicate to send 415 error code
     */
    private Packet decodePacket(@NotNull WSHTTPConnection con, @NotNull Codec codec) throws IOException {
        String ct = con.getRequestHeader("Content-Type");
        InputStream in = con.getInput();
        Packet packet = new Packet();
        packet.soapAction = fixQuotesAroundSoapAction(con.getRequestHeader("SOAPAction"));
        packet.wasTransportSecure = con.isSecure();
        packet.acceptableMimeTypes = con.getRequestHeader("Accept");
        packet.addSatellite(con);
        packet.transportBackChannel = new Oneway(con);
        packet.webServiceContextDelegate = con.getWebServiceContextDelegate();
    
        if (dump) {
            ByteArrayBuffer buf = new ByteArrayBuffer();
            buf.write(in);
            in.close();
            dump(buf, "HTTP request", con.getRequestHeaders());
            in = buf.newInputStream();
        }
        codec.decode(in, ct, packet);
        return packet;
    }
    
    /**
     * Some stacks may send non WS-I BP 1.2 conformant SoapAction.
     * Make sure SOAPAction is quoted as {@link Packet#soapAction} expectsa quoted soapAction value.
     *
     * @param soapAction SoapAction HTTP Header
     * @return
     */
    private String fixQuotesAroundSoapAction(String soapAction) {
        if(soapAction != null && (!soapAction.startsWith("\"") || !soapAction.endsWith("\"")) ) {
            LOGGER.warning("Received WS-I BP non-conformant Unquoted SoapAction HTTP header: "+ soapAction);
            String fixedSoapAction = soapAction;
            if(!soapAction.startsWith("\""))
                fixedSoapAction = "\"" + fixedSoapAction;
            if(!soapAction.endsWith("\""))
                fixedSoapAction = fixedSoapAction + "\"";
            return fixedSoapAction;
        }
        return soapAction;
    }
    

    SOAP Action 由命名空间和需要调用的实际方法组成。 此外,需要将 SOAP Action 封装在“”中才能工作。 下面的辅助方法可用于生成 SOAP Action:

    public String getSoapAction(String method) {
        return "\"" + NAMESPACE + method + "\""; 
    }
    

    希望这能回答您的问题。

    【讨论】:

    • 对不起,但是你怎么知道这个代码是负责 OP 收到的警告的?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-03-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多