簡體   English   中英

Camel-CXF在Apache Karaf中運行時不添加soap:Header to Request

[英]Camel-CXF doesn't add soap:Header to Request when run inside Apache Karaf

我使用Camel(2.16.3)來調用Webservice(參見下面的WSDL)。 如果我使用camel:run maven命令運行我的Route Standalone,一切正常,請求就像這樣:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
    <soap:Header>
        <Action xmlns="http://www.w3.org/2005/08/addressing">http://tempuri.org/OutboundItemTransferIISWebService/OutboundItemTransferIISWebService/ItemTransfer</Action>
        <MessageID xmlns="http://www.w3.org/2005/08/addressing">urn:uuid:17fba6c9-daa8-41cb-a5a5-2806165d705b</MessageID>
        <To xmlns="http://www.w3.org/2005/08/addressing">http://localhost:8765/wc3/entw/OutboundItemTransferIISWebService.svc</To>
        <ReplyTo xmlns="http://www.w3.org/2005/08/addressing">
            <Address>http://www.w3.org/2005/08/addressing/anonymous</Address>
        </ReplyTo>
    </soap:Header>
    <soap:Body>
        <ns2:ItemTransfer xmlns="urn:microsoft-dynamics-nav/xmlports/x60780" xmlns:ns2="http://tempuri.org/OutboundItemTransferIISWebService/"><ns2:p_OutboundItem/>
            <ns2:p_ItemFilter></ns2:p_ItemFilter>
            <ns2:p_ItemMaxFilter>100</ns2:p_ItemMaxFilter>
        </ns2:ItemTransfer>
    </soap:Body>
</soap:Envelope>

但是,如果我將我的項目部署到Karaf(4.0.4)安裝並觸發請求,則會丟失soap:Header:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
    <soap:Body>
        <ns2:ItemTransfer xmlns="urn:microsoft-dynamics-nav/xmlports/x60780" xmlns:ns2="http://tempuri.org/OutboundItemTransferIISWebService/"><ns2:p_OutboundItem/>
            <ns2:p_ItemFilter></ns2:p_ItemFilter>
            <ns2:p_ItemMaxFilter>100</ns2:p_ItemMaxFilter>
        </ns2 :ItemTransfer>
    </soap:Body>
</soap:Envelope>

因為對於被調用的服務器,需要Header,所以我得到了SOAP Fault。


附件

遵循定義CXF端點的Spring配置:

<cxf:cxfEndpoint id="itemTransfer"
    address="${navision.ws.base.url}/OutboundItemTransferIISWebService.svc"
    wsdlURL="wsdl/OutboundItemTransferIISWebService.wsdl"
    serviceClass="org.tempuri.outbounditemtransferiiswebservice.OutboundItemTransferIISWebService"
    endpointName="ns:WSHttpBinding_OutboundItemTransferIISWebService"
    serviceName="ns:OutboundItemTransferIISWebService"
    xmlns:ns="http://tempuri.org/OutboundItemTransferIISWebService/"
    loggingFeatureEnabled="true">
</cxf:cxfEndpoint>

以及觸發請求的Route(在Java DSL中):

from(ACTIVEMQ_UPDATE_ITEMS).routeId("Read all Items from the Webservice into MongoDB")
    .log(LoggingLevel.INFO, logger, "Read the next {{navision.ws.chunk.size}} Items! Filter: '${body}'")
    .setHeader(Masterdata.HEADER_CHUNK_SIZE).simple("{{navision.ws.chunk.size}}")
    .bean(InitialItemImport.class, "createItemTransferRequest")
    .to("cxf:bean:itemTransfer?dataFormat=POJO")
    .bean(InitialItemImport.class, "itemTransferResponseToList")
    .split(body()).parallelProcessing()
        .bean(InitialItemImport.class, "convertItemToUpsert")
        .to("mongodb:mongo?database={{mongo.database}}&collection=articles&operation=update")
    .end()
    .choice()
        .when(method(InitialItemImport.class, "shouldTriggerNext"))
            .bean(InitialItemImport.class, "createNextFilter")
            .to(ACTIVEMQ_UPDATE_ITEMS)
        .otherwise()
            .log(LoggingLevel.INFO, logger, "Finished Full-Update of Items")
    .end();

以及定義服務的WSDL:

<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions name="OutboundItemTransferIISWebService"
    targetNamespace="http://tempuri.org/OutboundItemTransferIISWebService/"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex"
    xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:tns="http://tempuri.org/OutboundItemTransferIISWebService/"
    xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
    xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
    xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy"
    xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract"
    xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
    xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
    <wsp:Policy wsu:Id="WSHttpBinding_OutboundItemTransferIISWebService_policy">
        <wsp:ExactlyOne>
            <wsp:All>
                <wsaw:UsingAddressing />
            </wsp:All>
        </wsp:ExactlyOne>
    </wsp:Policy>
    <wsdl:types>
        <xsd:schema elementFormDefault="qualified"
            targetNamespace="http://tempuri.org/OutboundItemTransferIISWebService/">
            <xsd:element name="ItemTransfer">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element minOccurs="0" maxOccurs="1" name="p_OutboundItem"
                            type="q1:ItemData" xmlns:q1="urn:microsoft-dynamics-nav/xmlports/x60780" />
                        <xsd:element minOccurs="0" maxOccurs="1" name="p_ItemFilter"
                            type="xsd:string" />
                        <xsd:element minOccurs="1" maxOccurs="1" name="p_ItemMaxFilter"
                            type="xsd:int" />
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
            <xsd:element name="ItemTransferResponse">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element minOccurs="0" maxOccurs="1"
                            name="ItemTransferResult" type="q2:ItemData"
                            xmlns:q2="urn:microsoft-dynamics-nav/xmlports/x60780" />
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
        </xsd:schema>
        <xsd:schema elementFormDefault="qualified"
            targetNamespace="urn:microsoft-dynamics-nav/xmlports/x60780">
            <xsd:complexType name="ItemData" mixed="true">
                <xsd:sequence>
                    <xsd:element minOccurs="0" maxOccurs="unbounded" name="Item"
                        type="q3:Item" xmlns:q3="urn:microsoft-dynamics-nav/xmlports/x60780" />
                </xsd:sequence>
            </xsd:complexType>
            <xsd:complexType name="Item">
                <xsd:sequence>
                    <xsd:element minOccurs="0" maxOccurs="1" name="No"
                        type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1" name="No_2"
                        type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1" name="Description"
                        type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1"
                        name="Search_Description" type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1" name="Description_2"
                        type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1"
                        name="Base_Unit_of_Measure" type="xsd:string" />
                    <xsd:element minOccurs="1" maxOccurs="1"
                        name="Price_Unit_Conversion" type="xsd:int" />
                    <xsd:element minOccurs="1" maxOccurs="1" name="Unit_Price"
                        type="xsd:decimal" />
                    <xsd:element minOccurs="1" maxOccurs="1" name="Duty_Due_Percent"
                        type="xsd:decimal" />
                    <xsd:element minOccurs="0" maxOccurs="1" name="Duty_Code"
                        type="xsd:string" />
                    <xsd:element minOccurs="1" maxOccurs="1" name="Gross_Weight"
                        type="xsd:decimal" />
                    <xsd:element minOccurs="1" maxOccurs="1" name="Net_Weight"
                        type="xsd:decimal" />
                    <xsd:element minOccurs="1" maxOccurs="1" name="Unit_Volume"
                        type="xsd:decimal" />
                    <xsd:element minOccurs="0" maxOccurs="1" name="Freight_Type"
                        type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1" name="Tariff_No"
                        type="xsd:string" />
                    <xsd:element minOccurs="1" maxOccurs="1"
                        name="Duty_Unit_Conversion" type="xsd:decimal" />
                    <xsd:element minOccurs="0" maxOccurs="1"
                        name="Country_Region_Purchased_Code" type="xsd:string" />
                    <xsd:element minOccurs="1" maxOccurs="1" name="Blocked"
                        type="xsd:boolean" />
                    <xsd:element minOccurs="1" maxOccurs="1"
                        name="Price_Includes_VAT" type="xsd:boolean" />
                    <xsd:element minOccurs="0" maxOccurs="1"
                        name="VAT_Bus_Posting_Gr_Price" type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1"
                        name="Gen_Prod_Posting_Group" type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1"
                        name="Country_Region_of_Origin_Code" type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1" name="Tax_Group_Code"
                        type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1"
                        name="VAT_Prod_Posting_Group" type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1"
                        name="Manufacturer_Code" type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1"
                        name="Item_Category_Code" type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1"
                        name="Product_Group_Code" type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1"
                        name="Expiration_Calculation" type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1" name="Common_Item_No"
                        type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1"
                        name="Last_Date_Modified" type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1"
                        name="Recency_From_Date" type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1" name="Recency_To_Date"
                        type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1" name="Status_Code"
                        type="xsd:string" />
                    <xsd:element minOccurs="1" maxOccurs="1"
                        name="Rock_Bottom_Price" type="xsd:boolean" />
                    <xsd:element minOccurs="1" maxOccurs="1" name="Buy_Hit"
                        type="xsd:boolean" />
                    <xsd:element minOccurs="1" maxOccurs="1" name="Test_Winner"
                        type="xsd:boolean" />
                    <xsd:element minOccurs="1" maxOccurs="1" name="Inventory"
                        type="xsd:decimal" />
                    <xsd:element minOccurs="0" maxOccurs="1"
                        name="Item_Status_Display_Text" type="xsd:string" />
                    <xsd:element minOccurs="1" maxOccurs="1" name="Not_Homologated"
                        type="xsd:boolean" />
                    <xsd:element minOccurs="1" maxOccurs="1" name="Last_Direct_Cost"
                        type="xsd:decimal" />
                    <xsd:element minOccurs="1" maxOccurs="1" name="Unit_List_Price"
                        type="xsd:decimal" />
                    <xsd:element minOccurs="0" maxOccurs="unbounded" name="ItemVariant"
                        type="q4:ItemVariant" xmlns:q4="urn:microsoft-dynamics-nav/xmlports/x60780" />
                    <xsd:element minOccurs="0" maxOccurs="unbounded" name="ItemVendor"
                        type="q5:ItemVendor" xmlns:q5="urn:microsoft-dynamics-nav/xmlports/x60780" />
                    <xsd:element minOccurs="0" maxOccurs="unbounded" name="ItemSalesPrice"
                        type="q6:ItemSalesPrice" xmlns:q6="urn:microsoft-dynamics-nav/xmlports/x60780" />
                    <xsd:element minOccurs="0" maxOccurs="unbounded" name="ItemTranslation"
                        type="q7:ItemTranslation" xmlns:q7="urn:microsoft-dynamics-nav/xmlports/x60780" />
                    <xsd:element minOccurs="0" maxOccurs="unbounded"
                        name="ItemDistributionChannel" type="q8:ItemDistributionChannel"
                        xmlns:q8="urn:microsoft-dynamics-nav/xmlports/x60780" />
                </xsd:sequence>
            </xsd:complexType>
            <xsd:complexType name="ItemVariant">
                <xsd:sequence>
                    <xsd:element minOccurs="0" maxOccurs="1" name="Code"
                        type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1" name="Description"
                        type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1" name="Description_2"
                        type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1" name="Variant_Promo"
                        type="xsd:string" />
                    <xsd:element minOccurs="1" maxOccurs="1"
                        name="Variant_Inventory" type="xsd:decimal" />
                </xsd:sequence>
            </xsd:complexType>
            <xsd:complexType name="ItemVendor">
                <xsd:sequence>
                    <xsd:element minOccurs="0" maxOccurs="1" name="Vendor_No"
                        type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1"
                        name="Lead_Time_Calculation" type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1" name="Vendor_Item_No"
                        type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1" name="Variant_Code"
                        type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1" default="false"
                        name="Primary_Vendor" type="xsd:boolean" />
                </xsd:sequence>
            </xsd:complexType>
            <xsd:complexType name="ItemSalesPrice">
                <xsd:sequence>
                    <xsd:element minOccurs="0" maxOccurs="1" name="Sales_Type"
                        type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1" name="Sales_Code"
                        type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1" name="Starting_Date"
                        type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1" name="Currency_Code"
                        type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1" name="Variant_Code"
                        type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1"
                        name="Unit_Of_Measure_Code" type="xsd:string" />
                    <xsd:element minOccurs="1" maxOccurs="1" name="Minimum_Quantity"
                        type="xsd:decimal" />
                    <xsd:element minOccurs="0" maxOccurs="1" name="Ending_Date"
                        type="xsd:string" />
                    <xsd:element minOccurs="1" maxOccurs="1" name="Unit_Price"
                        type="xsd:decimal" />
                    <xsd:element minOccurs="1" maxOccurs="1"
                        name="Price_Includes_VAT" type="xsd:boolean" />
                    <xsd:element minOccurs="0" maxOccurs="1"
                        name="VAT_Bus_Posting_Grp_Price" type="xsd:string" />
                    <xsd:element minOccurs="1" maxOccurs="1" name="Action_Price"
                        type="xsd:boolean" />
                </xsd:sequence>
            </xsd:complexType>
            <xsd:complexType name="ItemTranslation">
                <xsd:sequence>
                    <xsd:element minOccurs="0" maxOccurs="1" name="Variant_Code"
                        type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1" name="Language_Code"
                        type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1" name="Description"
                        type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1" name="Description_2"
                        type="xsd:string" />
                </xsd:sequence>
            </xsd:complexType>
            <xsd:complexType name="ItemDistributionChannel">
                <xsd:sequence>
                    <xsd:element minOccurs="0" maxOccurs="1" name="Item_No"
                        type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1" name="Variant_Code"
                        type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1"
                        name="Responsibility_Center" type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1" name="Start_Date"
                        type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1"
                        name="Distribution_Channel_Code" type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1" name="Item_Description"
                        type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1"
                        name="Item_Description_2" type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1" name="Language_Code"
                        type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1" name="Promo_From_Date"
                        type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1" name="Promo_Until_Date"
                        type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1"
                        name="Recency_From_Date_Distr" type="xsd:string" />
                    <xsd:element minOccurs="0" maxOccurs="1"
                        name="Recency_To_Date_Distr" type="xsd:string" />
                </xsd:sequence>
            </xsd:complexType>
        </xsd:schema>
    </wsdl:types>
    <wsdl:message
        name="OutboundItemTransferIISWebService_ItemTransfer_InputMessage">
        <wsdl:part name="parameters" element="tns:ItemTransfer" />
    </wsdl:message>
    <wsdl:message
        name="OutboundItemTransferIISWebService_ItemTransfer_OutputMessage">
        <wsdl:part name="parameters" element="tns:ItemTransferResponse" />
    </wsdl:message>
    <wsdl:portType name="OutboundItemTransferIISWebService">
        <wsdl:operation name="ItemTransfer">
            <wsdl:input
                wsaw:Action="http://tempuri.org/OutboundItemTransferIISWebService/OutboundItemTransferIISWebService/ItemTransfer"
                message="tns:OutboundItemTransferIISWebService_ItemTransfer_InputMessage" />
            <wsdl:output
                wsaw:Action="http://tempuri.org/OutboundItemTransferIISWebService/OutboundItemTransferIISWebService/ItemTransferResponse"
                message="tns:OutboundItemTransferIISWebService_ItemTransfer_OutputMessage" />
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="WSHttpBinding_OutboundItemTransferIISWebService"
        type="tns:OutboundItemTransferIISWebService">
        <wsp:PolicyReference
            URI="#WSHttpBinding_OutboundItemTransferIISWebService_policy" />
        <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
        <wsdl:operation name="ItemTransfer">
            <soap12:operation
                soapAction="http://tempuri.org/OutboundItemTransferIISWebService/OutboundItemTransferIISWebService/ItemTransfer"
                style="document" />
            <wsdl:input>
                <soap12:body use="literal" />
            </wsdl:input>
            <wsdl:output>
                <soap12:body use="literal" />
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="OutboundItemTransferIISWebService">
        <wsdl:port name="WSHttpBinding_OutboundItemTransferIISWebService"
            binding="tns:WSHttpBinding_OutboundItemTransferIISWebService">
            <soap12:address
                location="http://mdnmt2.ms.local/wc3/entw/OutboundItemTransferIISWebService.svc" />
            <wsa10:EndpointReference>
                <wsa10:Address>http://mdnmt2.ms.local/wc3/entw/OutboundItemTransferIISWebService.svc</wsa10:Address>
            </wsa10:EndpointReference>
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

在Karaf中安裝cxf-ws-addrfeature:install cxf-ws-addr )。

這似乎是apache karaf的camel-cxf功能中的缺失或錯誤依賴。

從一開始

就像我之前提到的那樣,我添加了一個攔截器,它應該添加動作頭,這沒有用。 所以我調試了我的Request的整個Interceptor-Chain並檢查了每個Interceptor正在做什么(是的,每個Interceptor)。 為了找到差異,我已經為獨立和karaf的遠程調試做了這個。

我發現,前面提到的Interceptor沒有做任何有用的事情(所以不要使用它),而在karaf中,根本沒有使用Interceptor org.apache.cxf.ws.addressing.impl.MAPAggregatorImpl 我檢查了已安裝的bundle和maven的依賴樹,實際上,maven依賴camel-cxf引用了cxf-rt-ws-addr (包含Interceptor)。 但卡拉夫的功能卻沒有。

這真的很討厭,因為(在我看來)捆綁功能的一個好處是,它們代表了maven依賴層次結構,我不需要自己管理它們!

暫無
暫無

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

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