0

我是网络服务的新手,不知何故,我使用 wso2 esb 4.0.6 通过 http/https 创建了一个简单的网络服务。现在我的要求是从响应中删除标签,即我需要纯文本作为响应,下面的代码片段将让您简要了解我的要求。

<case regex="POST">
   <property name="HTTP_METHOD" value="POST" scope="axis2" type="STRING"/>
       <enrich>
     <source type="inline" clone="true">
         <success xmlns="">Your request for subscription is being processed.</success>
     </source>
     <target type="body"/>
    </enrich>
     <header name="To" action="remove"/>
      <property name="NO_ENTITY_BODY" scope="axis2" action="remove"/>
      <property name="RESPONSE" value="true" scope="default" type="STRING"/>
      <property name="ContentType" value="text/plain" scope="axis2"/>
</case>

我能够得到以下回复<success>Your request for subscription is being processed.</success>

我只想<success> </success>从响应中删除标签。

提前致谢

4

2 回答 2

2

可能这有点晚了,但我最近也遇到了这个问题,这就是你如何让它工作的方法。

  1. 确保在 ESB/repository/conf/axis2/axis2.xml 中启用了 plainTextFormatter。
  2. 在您的代理服务中设置“messageType”属性,如下所示

  3. 添加有效负载文本元素。请参考下面给出的示例代理服务的出序列

<outSequence>
         <payloadFactory>
            <format>
               <ms11:text xmlns:ms11="http://ws.apache.org/commons/ns/payload">$1</ms11:text>
            </format>
            <args>
               <arg xmlns:ns="http://www.wso2.org/types" expression="$body/ns:greetResponse/return/text()"/>
            </args>
         </payloadFactory>
         <property name="messageType" value="text/plain" scope="axis2"/>
         <log level="full"/>
         <send/>
      </outSequence>

在这种情况下,我从后端服务 (HelloService) 的响应如下。

<?xml version='1.0' encoding='utf-8'?> 
  <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"> 
  <soapenv:Body> 
    <ns:greetResponse xmlns:ns="http://www.wso2.org/types"> 
      <return>Hello World, Test !!!</return> 
   </ns:greetResponse> 
 </soapenv:Body> 
</soapenv:Envelope> 

请参阅下面使用 curl 命令的 GET 请求的请求和响应

curl -X GET "http://localhost:8280/services/TestProxy/greet?name=Test" -v 
* About to connect() to localhost port 8280 (#0) 
* Trying 127.0.0.1... connected 
> GET /services/TestProxy/greet?name=Test HTTP/1.1 
> User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3 
> Host: localhost:8280 
> Accept: */* 
> 
< HTTP/1.1 200 OK 
< Content-Type: text/plain; charset=UTF-8 
< Server: WSO2 Carbon Server 
< Vary: Accept-Encoding 
< Date: Wed, 25 Sep 2013 06:08:21 GMT 
< Transfer-Encoding: chunked 
< 
* Connection #0 to host localhost left intact 
* Closing connection #0 
Hello World, Test !!! 

谢谢萨吉特

于 2013-09-25T06:38:10.117 回答
0

只需将整个信封定义为内联源。例如:

 <inSequence>
         <enrich>
            <source type="inline" clone="true">
               <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">                        
                  <soapenv:Body>     Your request for subscription is being processed.   </soapenv:Body>               
               </soapenv:Envelope>
            </source>
            <target type="envelope"/>
         </enrich>
         <header name="To" action="remove"/>
         <property name="RESPONSE" value="true" scope="default" type="STRING"/>
         <property name="Content-Type" value="text/plain" scope="transport" type="STRING"/>
         <send/>
      </inSequence>
于 2013-05-20T16:55:44.423 回答