Reputation: 1205
I need to use a Soap API and expose it as REST.
Something just like the Weather API discussed in this Apigee tutorial/doc http://docs.apigee.com/tutorials/proxy-soap-service
However, in my case, instead of using a rest GET, I have to use a rest POST with the parameters in a json payload.
So instead of doing this
GET http://myapi.apigee.net/weatherrest/cityweatherbyzip?ZIP=07030
I need to do this:
POST http://myapi.apigee.net/weatherrest/cityweatherbyzip
{
"ZIP":07030
}
with apigee taking the parameter from the posted json payload and making the normal SOAP call with it.
At the moment, it doesn't seem to work, the call reaches the target but without the parameter. It returns:
{
"GetCityWeatherByZIPResponse":{
"GetCityWeatherByZIPResult":{
"Success":"false",
"ResponseText":"Invalid ZIP",
"State":{
},
"City":{
},
"WeatherStationCity":{
},
"WeatherID":-1,
"Description":{
},
"Temperature":{
},
"RelativeHumidity":{
},
"Wind":{
},
"Pressure":{
},
"Visibility":{
},
"WindChill":{
},
"Remarks":{
}
}
}
}
What should i do to make sure parameters are taken from my json payload and propagated to the SOAP target call? Many Thanks
Upvotes: 0
Views: 376
Reputation: 1205
Actually, this is all related to those ExtractVariable block.
See this: http://docs.apigee.com/api-services/reference/extract-variables-policy
So in this case, something like this should be used:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables async="false" continueOnError="true" enabled="true" name="GetCityWeatherByZIP-extract-form-param">
<DisplayName>GetCityWeatherByZIP Extract Form Param</DisplayName>
<Source clearPayload="true|false">request</Source>
<JSONPayload>
<Variable name="ZIP" type="string">
<JSONPath>$.ZIP</JSONPath>
</Variable>
</JSONPayload>
<IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
</ExtractVariables>
in Api > Develop > policy (the one corresponding to the first step of your PUT)
Upvotes: 1