阿皮吉;Rest > Soap(使用 POST),json 有效负载参数不会传播



我需要使用一个 Soap API 并将其公开为 REST。

就像这个 Apigee 教程/文档中讨论的天气 API 一样http://docs.apigee.com/tutorials/proxy-soap-service

但是,就我而言,我必须使用带有 json 有效负载中的参数的 rest POST,而不是使用 rest GET。

所以与其这样做

获取 http://myapi.apigee.net/weatherrest/cityweatherbyzip?ZIP=07030

我需要这样做:

发布 http://myapi.apigee.net/weatherrest/cityweatherbyzip

{
    "ZIP":07030
}

使用 apigee 从发布的 JSON 有效负载中获取参数并使用它进行正常的 SOAP 调用。

目前,它似乎不起作用,调用到达目标但没有参数。它返回:

{
    "GetCityWeatherByZIPResponse":{
        "GetCityWeatherByZIPResult":{
            "Success":"false",
            "ResponseText":"Invalid ZIP",
            "State":{
            },
            "City":{
            },
            "WeatherStationCity":{
            },
            "WeatherID":-1,
            "Description":{
            },
            "Temperature":{
            },
            "RelativeHumidity":{
            },
            "Wind":{
            },
            "Pressure":{
            },
            "Visibility":{
            },
            "WindChill":{
            },
            "Remarks":{
            }
        }
    }
}

我应该怎么做才能确保参数从我的 json 有效负载中获取并传播到 SOAP 目标调用?非常感谢

实际上,这一切都与那些 ExtractVariable 块有关。

看到这个:http://docs.apigee.com/api-services/reference/extract-variables-policy

所以在这种情况下,应该使用这样的东西:

<?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>

在 API> 制定>策略(与您的 PUT 的第一步相对应)

最新更新