调用SOAP Web服务时出现警告消息

时间:2014-05-28 14:31:30

标签: web-services soap

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

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

有人可以告诉我如何解决它吗?

1 个答案:

答案 0 :(得分: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需要封装在“”中才能工作。 helper方法可以用于生成SOAP Action:

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

希望这会回答你的问题。