如何使用 wso2 ei 更新 soap 响应命名空间值
how to update soap response namespace value with wso2 ei
我有一个代理服务可以在 wso2 ei 上公开 soap api,我需要用我的代理服务和 return 另一个命名空间值更新 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>
我收到这个错误。
ERROR - EnrichMediator Invalid Target object to be enrich.
我的实际肥皂反应如下
<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>
欢迎您的所有反馈
试试这个。
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>
enrich 介体无法做到这一点。因为在enrich mediator target handling相关的代码中[1],xpath表达式的解析结果应该是SOAPHeaderImpl、OMElement、OMText或OMAttribute之一。由于 namespace-uri() 只是返回一个字符串值,因此要丰富的目标变得无效。作为此用例的替代方案,我们可以使用 XSLT 中介器进行 XSLT 转换。以下是我尝试过的示例 XSL 样式 sheet。
<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 调解器中引用此样式 sheet。新命名空间将添加到正文中。
我有一个代理服务可以在 wso2 ei 上公开 soap api,我需要用我的代理服务和 return 另一个命名空间值更新 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>
我收到这个错误。
ERROR - EnrichMediator Invalid Target object to be enrich.
我的实际肥皂反应如下
<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>
欢迎您的所有反馈
试试这个。
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>
enrich 介体无法做到这一点。因为在enrich mediator target handling相关的代码中[1],xpath表达式的解析结果应该是SOAPHeaderImpl、OMElement、OMText或OMAttribute之一。由于 namespace-uri() 只是返回一个字符串值,因此要丰富的目标变得无效。作为此用例的替代方案,我们可以使用 XSLT 中介器进行 XSLT 转换。以下是我尝试过的示例 XSL 样式 sheet。
<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 调解器中引用此样式 sheet。新命名空间将添加到正文中。