【问题标题】:Apigee; Rest > Soap (using POST), json payload parameters are not propagatedApigee; Rest > Soap(使用 POST),不传播 json 有效负载参数
【发布时间】:2016-05-10 00:41:07
【问题描述】:

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

类似于此 Apigee 教程/文档中讨论的 Weather 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 目标调用?非常感谢

【问题讨论】:

    标签: json rest soap apigee


    【解决方案1】:

    实际上,这都与那些 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第一步)

    【讨论】:

    • 这完全正确。您必须通过提取变量和构建 SOAP 消息来构建您的 SOAP 请求。
    猜你喜欢
    • 1970-01-01
    • 2015-07-05
    • 1970-01-01
    • 2021-05-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-27
    • 2015-05-07
    相关资源
    最近更新 更多