繁体   English   中英

如何使用wso2 ei更新soap响应名称空间值

[英]how to update soap response namespace value with wso2 ei

我有一个代理服务来公开wso2 ei上的soap api,我需要用我的代理服务更新soap响应的名称空间值并返回另一个名称空间值。 我已经在丰富的调解人中尝试了以下方法。

<property name="namespace"
               scope="default"
               type="STRING"
               value="http://tempuri-updated.org/"/>
      <enrich>
        <source clone="false" property="namespace" type="property"/>
        <target xmlns:ser="http://services.samples"
                xmlns:ns="http://org.apache.synapse/xsd"
                xpath="namespace-uri($body/*)/text()"/>
     </enrich>

我得到这个错误。

错误-要充实的EnrichMediator无效的Target对象。

我的实际肥皂反应如下

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <AddResponse xmlns="http://tempuri.org/">
         <AddResult>12</AddResult>
      </AddResponse>
   </soap:Body>
</soap:Envelope>

我的预期输出如下

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <AddResponse xmlns="http://tempuri-updated.org/">
         <AddResult>12</AddResult>
      </AddResponse>
   </soap:Body>
</soap:Envelope>

欢迎您提供所有反馈

富中介者无法做到这一点。 因为在与丰富介体目标处理相关的代码中[1] ,所以xpath表达式的解析结果应该是SOAPHeaderImpl,OMElement,OMText或OMAttribute之一。 由于namespace-uri()仅返回字符串值,因此要丰富的目标变得无效。 作为此用例的替代方案,我们可以使用XSLT中介程序进行XSLT转换。 以下是我尝试过的示例XSL样式表。

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="@* | comment() | processing-instruction()">
    <xsl:copy/>
    </xsl:template>

   <xsl:template match="*">
       <xsl:element name="{local-name()}"
             namespace="http://tempuri-updated.org/">
       <xsl:apply-templates select="@* | node()"/>
       </xsl:element>
    </xsl:template>

在从EI发送响应之前,我们可以在XSLT中介器中引用此样式表。 新的名称空间将添加到主体中。

尝试这个。

http://codertechblog.com/wso2-change-payload-soap-envelope-namespace/

<sequence name="seTestChangeNamespace" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
(...)
<enrich>
<source type="body"/>
<target type="property" property="INPUT_MESSAGE"/>
</enrich>
<enrich>
<source type="inline">
<myns:Envelope xmlns:myns="http://schemas.xmlsoap.org/soap/envelope/">
<myns:Body/>
</myns:Envelope>
</source>
<target type="envelope"/>
</enrich>
<enrich>
<source type="property" property="INPUT_MESSAGE"/>
<target type="body"/>
</enrich>
(...)
</sequence>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM