如何使用“\ /”或“|”等特殊符号发布参数在https://apigee.com GET api请求?

时间:2018-03-13 16:36:19

标签: apigee

我们正在尝试在移动应用中使用外部SOAP服务。我们正在使用https://apigee.com将该SOAP服务转换为GET方法REST API。但是当遇到实际的SOAP api时,REST api正在改变我们的参数值(包含一些像/ |和all这样的特殊字符)。我们如何在Apigee中停止这个编码/解码部分?是他们为此目的提供的其他免费服务吗?

1 个答案:

答案 0 :(得分:0)

REST API GET请求。因此,您将在URL中发送请求参数作为查询参数。使用以下流程

  1. 使用“提取变量”策略提取查询参数变量
  2. 
    
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <ExtractVariables async="false" continueOnError="true" enabled="true" name="getqueryparams">
        <DisplayName>getqueryparams</DisplayName>
        <QueryParam name="param1">
            <Pattern ignoreCase="true">{param1}</Pattern>
        </QueryParam>
        <QueryParam name="param2">
            <Pattern ignoreCase="true">{param2}</Pattern>
        </QueryParam>
        <QueryParam name="param3">
            <Pattern ignoreCase="true">{param3}</Pattern>
        </QueryParam>
        <Source>request</Source>
        <VariablePrefix>getqueryparams</VariablePrefix>
        <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
    </ExtractVariables>
    &#13;
    &#13;
    &#13;

    1. 使用服务标注策略创建和发送SOAP POST请求
    2. &#13;
      &#13;
      <ServiceCallout async="false" continueOnError="false" enabled="true" name="Service-Callout-1">
          <DisplayName>Custom label used in UI</DisplayName>
          <Request clearPayload="true" variable="myRequest">
              <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
              <Set>
              <Headers>
                  <Header name="Content-Type">text/xml</Header> 
                  <Header name="SOAPAction">http://www.webserviceX.NET/GetWeather</Header>
              </Headers>
              <Payload contentType="text/xml">
                  <?xml version="1.0" encoding="utf-8"?>
                  <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
                    <soap:Body>
                      <GetWeather xmlns="http://www.webserviceX.NET">
                        <CityName>{getqueryparams.param1}</CityName>
                        <CountryName>{getqueryparams.param2}</CountryName>
                      </GetWeather>
                    </soap:Body>
                  </soap:Envelope>
              </Payload>
              <Verb>POST</Verb>
              </Set>
          </Request>
          <Response>response</Response>
          <Timeout>60000</Timeout>
          <HTTPTargetConnection>
              <URL>http://www.webservicex.com/globalweather.asmx</URL>
          </HTTPTargetConnection>
      </ServiceCallout>
      &#13;
      &#13;
      &#13;

      1. 使用xml到json策略将响应xml转换为RESPONSE流中的JSON
      2. 您的服务网址:http://superman-prod.apigee.net/service/getService?param1=abc/xyz&param2=one|two&param3=omgomgomg