From Talend ESB, you can use policies in the Service Registry to validate WSDL schemas. This validation will be performed using the service schema defined in the WSDL.
Talend ESB provides a template policy called wspolicy_schema_validation.policy and available in the /add-ons/registry/policies folder of the Talend ESB product. This default policy for schema validation is as follows:
<wsp:Policy xmlns:wsp="http://www.w3.org/ns/ws-policy" Name="wspolicy_schema_validation"> <wsp:ExactlyOne> <wsp:All> <tpa:SchemaValidation xmlns:tpa="http://types.talend.com/policy/assertion/1.0" type="WSDLSchema" appliesTo="provider" message="request"/> </wsp:All> </wsp:ExactlyOne> </wsp:Policy>
type- WSDLSchema (if not specified, assumed as WSDLSchema),
To enable WSDL Schema Validation via policy:
Make sure the Talend Runtime is running, and the Service Registry service has been started. For more information, see the Talend ESB Container Administration Guide.
Import the WDSL schema validation policy to use, either directly from the Talend Runtime. For more information, see Using the Service Registry with Talend ESB or via the Talend Administration Center, for more information, see the Talend Administration Center User Guide.
This wspolicy_schema_validation.policy policy is by default applicable for provider's request, but you can modify it according to your need. For more information about the customization or creation of your own validation policy, refer to the Custom Schema Validation Policy.
Assign the policy to the service you want to validate the schema of.
xsd:schema, for example:
<xsd:restriction base="xsd:string"> <xsd:minLength value="20"></xsd:minLength> <xsd:maxLength value="30"></xsd:maxLength> </xsd:restriction>
If this restriction is defined in the
<xsd:element> of the
request, then it will be used to validate the request message on the consumer,
provider (or both) side. If this restriction is defined in the
<xsd:element> of the response, then it will be used to validate
the response message on the consumer, provider, or always.
In case the restriction is defined in the
<xsd:element> of the
request but you set your schema validation on the response element (the
message="response" parameter in the schema validation policy), then
the validation will not be taken into account.
In case the restriction is taken into account, the validity of the consumer, provider or both, request or response messages sent to the service will be checked at runtime when they will be deployed into the Talend Runtime Container. For example, if you send an invalid request to the service, for example a message of less than 20 characters, you will get a Fault response with validation failed information.