从 WSO2 ESB 版本 4.8.1 代理获取响应的问题
Issue with getting response from WSO2 ESB version 4.8.1 proxy
使用以下配置创建代理和目标 inSequence。该代理应该 return 响应,其中包含在有效负载中配置的内容,即 (<status>01SUCCESS</status>
)。正如预期的那样,wso2 4.9.0 中的响应是 <status>01SUCCESS</status>
。使用的客户端是 Apache HTTP 客户端。但同样 return wso2 esb 4.8.1 中的响应虽然状态为 200。在这两种情况下,Java 版本都是 1.7.0_79。
请建议任何适用于 WSO2 ESB 4.8.1 的解决方案?
代理服务器:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="buildResponse"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target inSequence="buildResponse" faultSequence="fault"/>
<description/>
</proxy>
序列:
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="buildResponse" xmlns="http://ws.apache.org/ns/synapse">
<property name="prop" scope="default" type="STRING" value="PROP"/>
<log>
<property expression="get-property('prop')" name="prop" xmlns:ns="http://org.apache.synapse/xsd"/>
</log>
<payloadFactory media-type="xml">
<format>
<status xmlns="">01SUCCESS</status>
</format>
</payloadFactory>
<log>
<property expression="$body" name="body" xmlns:ns="http://org.apache.synapse/xsd"/>
</log>
<header action="remove" name="To" scope="default"/>
<property name="RESPONSE" scope="default" type="STRING" value="true"/>
<send/>
</sequence>
如果您的请求是 GET 或 DELETE,您需要在发送调解器之前删除 NO_ENTITY_BODY:<property name="NO_ENTITY_BODY" scope="axis2" action="remove"/>
如果请求是 HTTP POST,序列中需要这个 属性,即使我们包含 HTTP GET 请求也没有任何问题。
<property name="messageType" value="text/xml" scope="axis2" type="STRING"/>
以下顺序配置适用于 HTTP GET 和 POST 请求;因为 POST 请求所需的 属性 也包含在配置中。
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="buildResponse" xmlns="http://ws.apache.org/ns/synapse">
<property name="prop" scope="default" type="STRING" value="PROP"/>
<log>
<property expression="get-property('prop')" name="prop" xmlns:ns="http://org.apache.synapse/xsd"/>
</log>
<payloadFactory media-type="xml">
<format>
<status xmlns="">01SUCCESS</status>
</format>
</payloadFactory>
<log>
<property expression="$body" name="body" xmlns:ns="http://org.apache.synapse/xsd"/>
</log>
<property name="messageType" value="text/xml" scope="axis2" type="STRING"/>
<property name="NO_ENTITY_BODY" scope="axis2" action="remove"/>
<header action="remove" name="To" scope="default"/>
<property name="RESPONSE" scope="default" type="STRING" value="true"/>
<send/>
</sequence>
使用以下配置创建代理和目标 inSequence。该代理应该 return 响应,其中包含在有效负载中配置的内容,即 (<status>01SUCCESS</status>
)。正如预期的那样,wso2 4.9.0 中的响应是 <status>01SUCCESS</status>
。使用的客户端是 Apache HTTP 客户端。但同样 return wso2 esb 4.8.1 中的响应虽然状态为 200。在这两种情况下,Java 版本都是 1.7.0_79。
请建议任何适用于 WSO2 ESB 4.8.1 的解决方案?
代理服务器:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="buildResponse"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target inSequence="buildResponse" faultSequence="fault"/>
<description/>
</proxy>
序列:
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="buildResponse" xmlns="http://ws.apache.org/ns/synapse">
<property name="prop" scope="default" type="STRING" value="PROP"/>
<log>
<property expression="get-property('prop')" name="prop" xmlns:ns="http://org.apache.synapse/xsd"/>
</log>
<payloadFactory media-type="xml">
<format>
<status xmlns="">01SUCCESS</status>
</format>
</payloadFactory>
<log>
<property expression="$body" name="body" xmlns:ns="http://org.apache.synapse/xsd"/>
</log>
<header action="remove" name="To" scope="default"/>
<property name="RESPONSE" scope="default" type="STRING" value="true"/>
<send/>
</sequence>
如果您的请求是 GET 或 DELETE,您需要在发送调解器之前删除 NO_ENTITY_BODY:<property name="NO_ENTITY_BODY" scope="axis2" action="remove"/>
如果请求是 HTTP POST,序列中需要这个 属性,即使我们包含 HTTP GET 请求也没有任何问题。
<property name="messageType" value="text/xml" scope="axis2" type="STRING"/>
以下顺序配置适用于 HTTP GET 和 POST 请求;因为 POST 请求所需的 属性 也包含在配置中。
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="buildResponse" xmlns="http://ws.apache.org/ns/synapse">
<property name="prop" scope="default" type="STRING" value="PROP"/>
<log>
<property expression="get-property('prop')" name="prop" xmlns:ns="http://org.apache.synapse/xsd"/>
</log>
<payloadFactory media-type="xml">
<format>
<status xmlns="">01SUCCESS</status>
</format>
</payloadFactory>
<log>
<property expression="$body" name="body" xmlns:ns="http://org.apache.synapse/xsd"/>
</log>
<property name="messageType" value="text/xml" scope="axis2" type="STRING"/>
<property name="NO_ENTITY_BODY" scope="axis2" action="remove"/>
<header action="remove" name="To" scope="default"/>
<property name="RESPONSE" scope="default" type="STRING" value="true"/>
<send/>
</sequence>