-2

We are trying to use an external SOAP service in our mobile app. We are converting that SOAP service into a GET method REST api using https://apigee.com. But that REST api , is changing our parameter value (which contain some special character like / | and all), when hitting actual SOAP api. How can we stop this encoding/decoding part in Apigee? is their any other free service available there for same purpose ?

Maitrayee
  • 1
  • 4

1 Answers1

0

REST API GET Request. So you will be sending request parameters in the URL as query parameters. Use the below flow

  1. Use Extract Variables policy to extract query parameter variables

<?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>
  1. Use Service callout policy to create and send SOAP POST Request

<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>
  1. Use xml to json policy to convert the response xml to JSON in RESPONSE flow

Your service URL: http://superman-prod.apigee.net/service/getService?param1=abc/xyz&param2=one|two&param3=omgomgomg

Nadhas
  • 5,421
  • 2
  • 28
  • 42