簡體   English   中英

CXF 2.7.7 org.apache.cxf.interceptor.Fault:意外元素

[英]CXF 2.7.7 org.apache.cxf.interceptor.Fault: Unexpected element

自升級到CXF 2.7.7以來,我遇到了我無法理解的錯誤。 進行Web服務調用時,CXF報告此異常:

org.apache.cxf.interceptor.Fault: 
Unexpected element {http://schema.myorg.com/GetReference/}ReferenceResponse found.
Expected {http://services.myorg.com/}getReferences

這沒有任何意義,因為ReferenceResponse正是我期望的響應。 名稱getReferences似乎是指被調用的@WebMethod批注方法的名稱。 此方法的返回類型為ReferenceResponse。

我想念什么?

我從未找到一個真正令人滿意的答案,但是當我用wsdl2cxf生成的現有客戶端接口替換了現有的客戶端接口時,該問題就解決了。 這還涉及從Xbeans遷移到JAXB進行封送處理,這可能與它有關。

但是,在此期間,向接口添加以下注釋可防止該錯誤。

@EndpointProperty(key = "soap.no.validate.parts", value = "true")

當發現默認情況下我的SOAPLoggingHandler在其方法中返回false時,我已經解決了該問題。 應該將其更改為true

public class SOAPLoggingHandler implements SOAPHandler<SOAPMessageContext> {
    @Override
    public Set<QName> getHeaders() {
        return null;
    }

    @Override
    public boolean handleMessage(SOAPMessageContext context) {
        SOAPMessage message= context.getMessage();
        boolean isOutboundMessage = (Boolean)context.get (MessageContext.MESSAGE_OUTBOUND_PROPERTY);
        if(isOutboundMessage){
            System.out.println("OUTBOUND MESSAGE\n");

        }else{
            System.out.println("INBOUND MESSAGE\n");
        }
        try {
            message.writeTo(System.out);
        } catch (SOAPException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        return true;

    }

    @Override
    public boolean handleFault(SOAPMessageContext context) {
        SOAPMessage message= context.getMessage();
        try {
            message.writeTo(System.out);
        } catch (SOAPException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        return true;
    }

    @Override
    public void close(MessageContext context) { }
}

我只是通過在我的應用程序代碼中添加自定義http標頭(特別是http keep live)來實現的。 ws客戶端http已被重用,並且看起來cxf並未在后續調用中重置soap action標頭。

暫無
暫無

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

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