Skip to content
Branch: master
Find file History
stephen gilson
stephen gilson fix zip file
Latest commit 5ebbae6 Oct 5, 2016
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
apiproxy refactored this sample to use mocktarget May 12, 2016
README.md added output May 17, 2016
deploy.sh refactored this sample to use mocktarget May 12, 2016
invoke.sh refactored this sample to use mocktarget May 12, 2016
variables.zip fix zip file Oct 5, 2016

README.md

Extract and assign variables

Sample use case

Extract variables from an XML and JSON response messages. Assign variables to HTTP response headers.

Policies

This sample uses these policies:

  • alt text Extract Variables: To pull subsets of data from the response body.
  • alt text XML to JSON: To convert the response from XML to JSON.
  • alt text Assign Message: To assign extracted data to response headers.
  • alt text Reads extracted variables so they are visible in the Trace tool.

About

  1. Extract variables from the XML response sent from the target. Use XPath syntax to identify the data to extract.
  2. Use JavaScript policy to read the variables. This allows them to show up in the Trace tool.
  3. Convert the response payload from XML to JSON.
  4. Extract more variables from the converted JSON payload. Use JSONPath syntax to identify the data to extract.
  5. Use JavaScript policy to read the variables. This allows them to show up in the Trace tool.
  6. Assign the extracted variables to HTTP response headers.

Set up, deploy, invoke

  1. Edit this script with your environment details: api-platform-samples/setup/setenv.sh

  2. ./deploy.sh

  3. invoke.sh

    The proxy returns these custom headers to the client:

    mock.city: San Jose
    mock.state: CA
    mock.firstName: John
    mock.lastName: Doe
    

See the main project README file for more detailed information about setting up, deploying, and invoking sample proxies.

Trace

This screen shot from the Apigee Edge trace tool shows the placement of the policies used in this sample.

alt text

More information

Related policies

Related topics

Ask the community

alt text


Copyright © 2016 Apigee Corporation

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

You can’t perform that action at this time.