我相信你在找什么是REST_URL_POSTFIX
财产。如果您设置了此属性,则该值将被附加到其余端点url。
它可以用axis2的范围定义如下。在此
<property name="REST_URL_POSTFIX"
expression="//client"
scope="axis2"
type="STRING"/>
的例子可以在本指南中找到,Using REST with a Proxy Service。
编辑:以下是使用curl的POST请求使用简单代理的示例。根据评论提供。在这里,我正在调用WSO2 Application Server中的jaxrs_basic rest服务。
curl -H "Content-Type: application/xml" -H "Accept: application/json" -d "<Customer><name>KasunG</name></Customer>" http://localhost:8281/services/new1/
。
curl -H "Content-Type: application/json" -H "Accept: application/json" -d "{ 'Customer' : { 'name' : 'KasunG' } } " http://localhost:8281/services/new1/
。
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="new1"
transports="https http"
startOnLoad="true"
trace="disable">
<description/>
<target>
<inSequence>
<property name="REST_URL_POSTFIX"
value="customers"
scope="axis2"
type="STRING"/>
<property name="ContentType" value="text/xml" scope="axis2" type="STRING"/>
<switch source="$axis2:HTTP_METHOD">
<case regex="GET">
<property name="HTTP_METHOD" value="GET" scope="axis2" type="STRING"/>
</case>
<case regex="POST">
<property name="messageType" value="application/json" scope="axis2"/>
<property name="ContentType"
value="application/JSON"
scope="axis2"
type="STRING"/>
<property name="HTTP_METHOD" value="POST" scope="axis2" type="STRING"/>
</case>
<default/>
</switch>
<send>
<endpoint>
<address uri="http://localhost:8888/jaxrs_basic/services/customers/customerservice"
format="rest"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<property name="messageType" value="application/json" scope="axis2"/>
<send/>
</outSequence>
</target>
</proxy>
我试过了。但它与Http GET很好。但是我打电话的Rest服务是Http POST。 REST_URL_POSTFIX属性似乎不适用于Http POST。 – bhaskar 2013-04-29 12:05:39
@bhaskar,我已经证实,上述属性起作用。我用一个简单的http代理尝试了这一点,但我不明白它对jms的不同。确保你设置的表达正确。您可以使用tcpmon来验证它最终调用哪个端点url。 WSO2 ESB默认运行tcpmon。 – 2013-04-29 12:32:41
我再次尝试了一个简单的http代理本身。但仍然无法使其工作。这是我正在使用的配置。 –
bhaskar
2013-04-29 15:54:48