簡體   English   中英

使用 HTTP header 中的 SOAPAction 來消費 ZC71E8D17D41C21DE0D1FFZ26088 中的 SOAP 服務

[英]Using SOAPAction in HTTP header to consume SOAP Service in JAVA

我正在嘗試使用 spring WebServiceGatewaySupport在 Java 中實現 soap 服務使用者。

當我使用curl來使用如下服務時,它會給出正確的響應。

 curl -d @request.xml -H 'SOAPAction:abc:mnEvent#DoAction' https://myhost.org/cd/doAction.jsp

我正在嘗試使用 JAVA 來實現相同的功能,方法是在繼承自WebServiceGatewaySupport的模板 class 中添加以下HttpHeaders

public O callWebService(String url, I request) {
    return (O) getWebServiceTemplate().marshalSendAndReceive(url, request, new WebServiceMessageCallback() {
        @Override
        public void doWithMessage(WebServiceMessage message) {
            TransportContext transportContext = TransportContextHolder.getTransportContext();
            HttpComponentsConnection connection = (HttpComponentsConnection) transportContext.getConnection();
            connection.getHttpPost().addHeader("SOAPAction", "abc:mnEvent#DoAction");
        }
    });
}

使用此代碼,我收到如下錯誤消息。

SOP-330006 方法 'DoAction, ""' 未在 SOAP 服務 'abc:mnEvent' 中定義。

curl命令移動到 JAVA 時,我在這里錯過了什么?

錯誤消息SOP-330006 The method 'DoAction, ""' is not defined in SOAP service 'abc:mnEvent'. 表示,請求中有兩個 soap 動作。

  1. 在 HttpHeader 中添加了顯式 SoapAction
  2. SoapMessage 中的隱式 SoapAction

為了避免這個問題,我們需要從 header 中刪除 soapAction 並將其設置在 SoapMessage 中。

SaajSoapMessage soapMessage = (SaajSoapMessage) message;
soapMessage.setSoapAction("abc:mnEvent#DoAction");

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM