The SOAPMessageValidation policy does the following:
Validates any XML message against their XSD schemas
Validates SOAP messages against a WSDL definition
Determines well-formedness of JSON and XML messages
While the name of this policy in the UI is SOAPMessageValidation, the policy validates more
than just SOAP messages. This section refers to the policy as the MessageValidation policy.
Message validation provides the following benefits:
Immediately informs app developers that are consuming your API if their
requests are non-conformant or incomplete.
Pinpoints issues in requests, such as XML tags that are not properly
closed.
Protects backend services by blocking XML or SOAP messages with structures
that might cause unpredictable behavior.
Reduces time spent troubleshooting, searching forums, or consulting with
tech support.
Encourages developers to familiarize themselves with the XML schema WSDL
definition to eliminate validation errors, making well-understood XML schemas a key component
of your API documentation.
This policy is a Standard policy and can be deployed to any environment type. For
information on policy types and availability with each environment type, see
Policy types.
Videos
Watch the following videos to learn more about the MessageValidation policy:
This element has the following attributes that are common to all policies:
Attribute
Default
Required?
Description
name
N/A
Required
The internal name of the policy. The value of the name attribute can
contain letters, numbers, spaces, hyphens, underscores, and periods. This value cannot
exceed 255 characters.
Optionally, use the <DisplayName> element to label the policy in
the management UI proxy editor with a different, natural-language name.
continueOnError
false
Optional
Set to false to return an error when a policy fails. This is expected behavior for
most policies. Set to true to have flow execution continue even after a policy
fails. See also:
Send a POST request to your API proxy with your XML as the message
payload, as the following example shows:
curl -v -X POST -H 'Content-Type: application/xml' http://my-test.apigee.net/v1/xsd-mock
-d '<note>
<to>Fred Rogers</to>
<from>Nick Danger</from>
<heading>Greetings from my neighborhood</heading>
<body>Just writing to say hello.</body>
</note>'
Notice that the Content-type header is set to application/xml.
You can also create a data file for the payload and reference it with a command
similar to the following:
You should receive an HTTP 200 response. Depending on your target endpoint,
you might receive addditional details about the request. For example, if you use
http://httpbin.org/post as your target endpoint and specify -v
(verbose) output, the response should be similar to the following:
You should receive an HTTP 200 response. Depending on your target endpoint,
you might receive addditional details about the request. For example, if you use
http://httpbin.org/post as your target endpoint, the response should be similar
to the following:
You can use the Message Validation policy to confirm that a JSON or XML message payload
is well-formed (not the same as validation). The policy ensures that the structure
and content meets accepted standards, including:
There is a single root element
There are no illegal characters in the content
Objects and tags are properly nested
Beginning and ending tags match
To check for a well-formed XML or JSON payload:
Add the SOAP Message Validation policy to your proxy endpoint's pre-flow.
Send a POST request to your API proxy, as the following example shows:
curl -v -X POST -H 'Content-Type: application/json' http://my-test.apigee.net/v1/xsd-mock
-d '{
"note": {
"to": "Fred Rogers",
"from": "Nick Danger",
"header": "Greetings from my neighborhood",
"body": "Just writing to say hello."
}
}'
Notice that the Content-type header is set to application/json.
To check an XML file for well-formedness, use XML as the message payload and
set Content-type to application/xml.
You should receive an HTTP 200 response. When you send a message payload
that does not contain well-formed XML or JSON, you should receive a
steps.messagevalidation.Failed error.
The value of <ResourceURL> must point to a resource
file in your API proxy. It cannot refer to external resources over HTTP or HTTPS.
If you do not specify a value for <ResourceURL>, the message is checked for well-formed JSON
or XML if the Content-type header is application/json or
application/xml,
respectively.
The <ResourceURL> element has no child elements or attributes.
Using XSDs for validation
If the XML payload that you validate with the MessageValidation policy references
another schema, you must prefix the included XSD file with xsd in the
schemaLocation attribute.
The following example schema is comprised of multiple XSDs:
Identifies the source message to be validated. The value of this element is the name of the
message that you want to validate.
If you do not set <Source>, this policy defaults to message, which refers to the complete
request message (in a request flow) or response message (in a response flow), including any
payload. You can also explicitly set it to request or response to refer to the request or
response.
In addition to message, request, and response, you can set the value of
<Source> to the name of any message in your flow. If you do this, though, you must create a
custom message with that name in your flow before this policy executes. Otherwise, you will get
an error.
If the value of <Source> cannot be resolved in the message flow or resolves to a non-message
type, then one of the following occurs:
If a null value: Apigee throws a
steps.messagevalidation.SourceMessageNotAvailable error.
If a non-message type: Apigee throws a
steps.messagevalidation.NonMessageVariable error.
The <Source> element has no attributes or child elements.
Error codes
This section describes the fault codes and error messages that are returned and fault variables that are set by Apigee when this policy triggers an error.
This information is important to know if you are developing fault rules to
handle faults. To learn more, see What you need to know
about policy errors and Handling
faults.
Runtime errors
These errors can occur when the policy executes.
Fault code
HTTP status
Cause
Fix
steps.messagevalidation.SourceMessageNotAvailable
500
This error occurs if a variable specified in the <Source> element
of the policy is either:
out of scope (not available in the specific flow where the policy is being executed)
This error occurs if the <Source> element in the SOAPMessageValidation
policy is set to a variable which is not of type
message.
Message type variables represent entire HTTP requests and responses. The built-in Apigee
flow variables request, response, and message are of type message. To learn more
about message variables, see the Variables reference.
This error occurs if the SOAPMessageValidation policy fails to validate the input message
payload against the XSD schema or WSDL definition. It will also occur if there is malformed
JSON or XML in the payload message.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-04-29 UTC."],[],[]]