You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WSO2日志属性缺失值问题:输出URL并用于Send Mediator

解决WSO2代理服务中SOAP Header URL获取及动态端点配置问题

我来帮你搞定这个WSO2代理服务的问题,你现在碰到的日志输出URL为空、没法把Header里的Endpoint用在Send Mediator的情况,主要是XPath表达式的命名空间处理和路径匹配问题,还有动态端点的配置方式不对,下面给你一步步解决:

问题根源分析

你当前的Property Mediator配置里,XPath表达式没有正确匹配到SOAP Header里的meta:Endpoint节点:

  • 没有声明soap命名空间,导致XPath无法识别soap:Header节点结构
  • 使用$header变量的方式在路径匹配上不够精准,容易出现节点定位失败

解决方案步骤

1. 修正Property Mediator,正确获取Endpoint值

需要同时声明soap和meta两个命名空间,并且用精准的XPath路径定位到Endpoint节点,加上/text()确保直接提取节点文本内容:

<property xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:meta="http://teswt.nl/xmlschemas/meeeeta/0.1" 
          expression="//soap:Header/meta:MetaDataType/meta:Endpoint/text()" 
          name="URL" scope="default" type="STRING"/>

2. 日志Mediator简化配置

日志里不需要重复声明命名空间,直接通过get-property读取已设置的属性即可:

<log level="custom">
    <property expression="get-property('URL')" name="URL"/>
</log>

3. 配置动态Send Mediator

把原来的固定URI改成动态引用属性的方式,用{get-property('URL')}替换固定地址,这样Send Mediator就会使用从Header里提取的URL:

<send>
    <endpoint>
        <address format="soap11" uri="{get-property('URL')}"/>
    </endpoint>
</send>

完整的InSequence代码

替换你原来的InSequence代码,就能实现目标1(日志打印正确URL)和目标2(动态使用该URL发送请求):

<inSequence>
    <property xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:meta="http://teswt.nl/xmlschemas/meeeeta/0.1" 
              expression="//soap:Header/meta:MetaDataType/meta:Endpoint/text()" 
              name="URL" scope="default" type="STRING"/>
    <log level="custom">
        <property expression="get-property('URL')" name="URL"/>
    </log>
    <send>
        <endpoint>
            <address format="soap11" uri="{get-property('URL')}"/>
        </endpoint>
    </send>
</inSequence>

这样配置后,日志就能正确打印出http://555.555.555.55:8088/sal,同时Send Mediator也会动态使用这个URL发送请求啦。

内容的提问来源于stack exchange,提问作者furion2000

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.08 22:12:46