gpt4 book ai didi

java - header 值在 Apache Camel Exchange 中为空

转载 作者:行者123 更新时间:2023-12-01 09:28:03 24 4
gpt4 key购买 nike

下面是我的网络服务请求、路由和请求 validator ,

网络服务请求:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<stlh:SabreHeader xmlns:stlh="http://services.sabre.com/STL_Header/v02_01">
<stlh:Service version="1.0.0">GetHotelMediaRQ</stlh:Service>
<stlh:Identification>
<stlh:CustomerID>CID12345</stlh:CustomerID>
<stlh:CustomerAppID>AppTest</stlh:CustomerAppID>
<stlh:ConversationID>05EFPElI2A4KudU75863JIxqAhQJtAx0</stlh:ConversationID>
<stlh:MessageID>4DTTQaHGSifFUtmSoMHAiq</stlh:MessageID>
<stlh:TimeStamp>2014-11-07T14:45:42.725-06:00</stlh:TimeStamp>
</stlh:Identification>
</stlh:SabreHeader>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:BinarySecurityToken EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" wsu:Id="athId">${athId}</wsse:BinarySecurityToken>
</wsse:Security>
</soap:Header>
<soap:Body>
<GetHotelMediaRQ xmlns="http://services.sabre.com/hotel/media/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0.0" xsi:schemaLocation="http://services.sabre.com/hotel/media/v1 GetHotelMediaRQ.xsd">
<HotelRefs>
<HotelRef HotelCode="184769" CodeContext="Sabre">
<ImageRef MaxImages="1">
<Images>
<Image Type="ORI"/>
</Images>
<AdditionalInfo>
<Info Type="CAPTION">true</Info>
</AdditionalInfo>
<Languages>
<Language Code="EN"/>
</Languages>
</ImageRef>
</HotelRef>
</HotelRefs>
</GetHotelMediaRQ>
</soap:Body>
</soap:Envelope>

请求 validator :

  public void validate(GetHotelMediaRQ request, Exchange exchange) throws Exception {
TransactionContext context = BusExtensions.getTransactionContext(exchange);
Collection<HotelRef> hotelRefList = getInstance().convert(request, Collection.class);
Set<Property> properties = new HashSet<>();
String customerAppId = exchange.getIn().getHeader("customerAppID", String.class);
String customerId = exchange.getIn().getHeader("customerID", String.class);

但是当我尝试通过 Exchange 对象访问时,customerAppId(AppTest) 和 CustomerId(CI12345) 为 null。

最佳答案

“自定义”Soap header 不会复制到 Camel header 。您必须手动将soap header 添加到camel交换 header 中。

方法1)

CamelCxfMessage - 您可以提取/处理存在于camel交换 header 中的自定义soap header camel cxf消息

骑 Camel -SoapMessagesoapMessage = (SoapMessage)exchange.getIn().getHeader("CamelCxfMessage");

这将为您提供soap消息及其soapMessage.getExchange,并尝试从soap消息获取soap header 并对其进行处理。

方法2)

Camel Cxf Binding - 您可以在端点定义中使用 Camel cxf 绑定(bind)功能,例如 cxfBinding=#bindingName

创建一个类并使用 org.apache.camel.component.cxf.DefaultCxfBinding 进行扩展,bean 名称应为 bindingName

它有一个你必须重写的方法 - propagateHeadersFromCxfToCamel(camelmessage ,cxfmessage ,exchage )。

在这里获取你的soap header ,并将其放入具有标识符的camel header 中,并在处理器或具有相同标识符的路由中的camel交换 header 中访问 header 。

关于java - header 值在 Apache Camel Exchange 中为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39679761/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com