Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

How to Parse a Query string Array Parameter using a SOAP proxy

Hi,

I am using Apigee to test a SOAP service using a SOAP PROXY

The service makes use of passing parameters from the REST GET and I have got this running ok

The parameter string is as follows

?string=variablename&startDate=Datetime&endDate=DateTime

Essentially I am trying to get data from an electricity meter for any meter variable over a selected period of time. This works fine when when the string variable is a single entity as shown below

http://gdiana-test.apigee.net/readingservice/loadprofilereadingsbyvariableids?string=kWh net int lp&startDate=2017-04-01T00:00:00.000&endDate=2017-04-01T00:30:00.000

and returns the correct variable and value

4592-apigee.png

The problem arises when I try to retrieve more than one variable.

The SOAP code generated by Apigee is as follows

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage async="false" continueOnError="true" enabled="true" name="GetLoadProfileReadingsByVariableIds-build-soap">
    <DisplayName>GetLoadProfileReadingsByVariableIds Build SOAP</DisplayName>
    <Add>
        <Headers>
            <Header name="SOAPAction">http://www.primestone.com/IntegrationServices/Readings/IReadingService/GetLoadProfileReadingsByVariableIds</Header>
        </Headers>
    </Add>
    <Set>
        <Headers>
            <Header name="Content-Type">text/xml; charset=utf-8</Header>
        </Headers>
        <Payload contentType="text/xml">
            <s11:Envelope xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/">
                <s11:Body>
                    <ns1:GetLoadProfileReadingsByVariableIds xmlns:ns1="http://www.primestone.com/IntegrationServices/Readings">
                        <!-- optional -->
                        <!-- This element may be left empty if xsi:nil='true' is set. -->
                        <ns1:variableIds>
                            <!-- from 0 to unbounded -->
                            <!-- This element may be left empty if xsi:nil='true' is set. -->
                            <q11:string xmlns:q11="http://schemas.microsoft.com/2003/10/Serialization/Arrays">{string}</q11:string>
                        </ns1:variableIds>

                        <!-- optional -->
                        <!--dateTime-->
                        <ns1:startDate>{startDate}</ns1:startDate>
                        <!-- optional -->
                        <!--dateTime-->
                        <ns1:endDate>{endDate}</ns1:endDate>
                    </ns1:GetLoadProfileReadingsByVariableIds>
                </s11:Body>
            </s11:Envelope>
        </Payload>
        <Verb>POST</Verb>
    </Set>
    <AssignVariable>
        <Name>forward.target.url</Name>
        <Value>http://197.242.156.221/PrimeIntegrationServices/ReadingService.svc</Value>
    </AssignVariable>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
    <AssignTo createNew="false" transport="http" type="request"/>
</AssignMessage>

The above code is populated by the Extract Policy (generated by Apigee) below

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables async="false" continueOnError="true" enabled="true" name="GetLoadProfileReadingsByVariableIds-extract-query-param">
    <DisplayName>GetLoadProfileReadingsByVariableIds Extract Query Param</DisplayName>
    <Source>request</Source>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
    <QueryParam name="string">
        <Pattern ignoreCase="true">{string}</Pattern>
    </QueryParam>
    <QueryParam name="startDate">
        <Pattern ignoreCase="true">{startDate}</Pattern>
    </QueryParam>
    <QueryParam name="endDate">
        <Pattern ignoreCase="true">{endDate}</Pattern>
    </QueryParam>
</ExtractVariables>

So as I understand matters the variable name gets extracted from the runstring to the Query Parameter string and the SOAP xml code should translate this into an xml string array, when more than one variable is used as shown below.

When using SOAP UI the following works fine and all three variables are returned as the array is correctly formulated.

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:read="http://www.primestone.com/IntegrationServices/Readings" xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
   <soapenv:Header/>
   <soapenv:Body>
      <read:GetLoadProfileReadingsByVariableIds>
         <!--Optional:-->
         <read:variableIds>
            <!--Zero or more repetitions:-->
            <arr:string>kWh net int lp</arr:string>
            <arr:string>kVARh net int lp</arr:string>
            <arr:string>kVAh net int lp</arr:string>
         </read:variableIds>
         <!--Optional:-->
         <read:startDate>2017-03-01T00:00:00.000</read:startDate>
         <!--Optional:-->
         <read:endDate>2017-04-01T00:30:00.000</read:endDate>
      </read:GetLoadProfileReadingsByVariableIds>
   </soapenv:Body>
</soapenv:Envelope>

Hence my question is how or what do I need to do to get Apigee to recreate this.

Is there any particular query parameter format I must use in the GET runstring but it appears I am unable to parse an array of variables named string of type string as a parameter.

Should it be ?string=variable1,variable2..........

But as I understand matters it needs to be returned as an array and the code sent to SOAP API should

see

            <arr:string>variable1</arr:string>
            <arr:string>variable2</arr:string>
            <arr:string>etc</arr:string>

Any help would be appreciated.

It appears the code below should do this ?

<ns1:variableIds>
<!-- from 0 to unbounded -->
<!-- This element may be left empty if xsi:nil='true' is set. -->
<q11:stringxmlns:q11="http://schemas.microsoft.com/2003/10/Serialization/Arrays">{string}</q11:string>
</ns1:variableIds>

Kind regards

Greg Diana

0 6 7,032
6 REPLIES 6
Top Solution Authors