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

XML命名空间前缀未绑定错误求助:types前缀绑定失败问题

问题排查:TypeError: 前缀"types"未绑定

错误信息

TypeError: The prefix "types" for element "types:ReceiveMessageResponse" is not bound.
at com.orchestral.rhapsody.modules.standard.filters.executescript.ExecuteScript.doProcessMessage(ExecuteScript.java:9)

问题根源

你的XML命名空间声明存在语法错误:soap命名空间的属性值未正确闭合单引号,后续多个命名空间的属性值也未用单引号包裹,导致XML解析器无法识别types前缀的绑定关系。

原代码中XML开头的错误写法:

<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/ xmlns:soapenc=http://schemas.xmlsoap.org/soap/encoding/ xmlns:tns=http://www.show.scot.nhs.uk/sci/gateway/messaging2.0 xmlns:types=http://www.show.scot.nhs.uk/sci/gateway/messaging2.0 xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:xsd=http://www.w3.org/2001/XMLSchema'>

可以看到xmlns:soap的单引号在URL结尾处缺失,后续所有命名空间定义都被解析成了soap命名空间值的一部分,自然无法绑定types前缀。

修正后的代码

var output = 
<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/' xmlns:tns='http://www.show.scot.nhs.uk/sci/gateway/messaging2.0' xmlns:types='http://www.show.scot.nhs.uk/sci/gateway/messaging2.0' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
  <soap:Body soap:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>
    <types:ReceiveMessageResponse>
      <ReceiveMessageResult href="#id1"/>
    </types:ReceiveMessageResponse>
    <types:GatewayAck id="id1" xsi:type="types:GatewayAck">
      <Code xsi:type="xsd:int">0</Code>
      <Detail xsi:type="xsd:string"/>
      <Source xsi:type="xsd:string"/>
      <UserMsg xsi:type="xsd:string"/>
    </types:GatewayAck>
  </soap:Body>
</soap:Envelope>

// 调整变量声明顺序:先定义output再使用
var next = output.append(input[0]);
next.xml = output;

额外修正点

原代码中var next = output.append(input[0]);写在var output定义之前,会触发output未定义的错误,需要调整变量声明顺序。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.14 03:05:26