This project is read-only.

Moving XSD Validation to the MSE Endpoint

May 28, 2009 at 11:22 PM


I'm attempting to move the Schema Validation on our service into MSE as an endpoint assertion.  We'd like to do this because we want to handle everything from malformed tags to bad values within the element such as 51 character string in a field that defines a 50 character maximum.  We have custom messages setup for our schema validation and when MSE attempts to deserialize the request and the tags are malformed MSE throws its own error instead of our custom error at validation on our service.  I've made some great strides in the last couple of days thanks to the source code and I am now able to successfully call the Schema.GetSchemaByNamespace method and the schema is returned.  

However, the XSD and ImportedSchemas objects are null so I am unable to use the CatalogSvcHelper.CreateXmlSchemaFromSchema method to convert the schema to the type necessary for validation.

Any ideas?

I'm sure I could get schema validation working on the MSE endpoint by embedding the schemas into my security assembly but since the schemas are already stored within the MSE Repository I'd like to use them from that location.  I think it makes the most sense...

Has schema validation at the MSE level even been considered up until now or am I the first to attempt something like this?

I look forward to hearing back from you soon.

Jul 9, 2009 at 3:59 AM

I was able to retrieve the schema XSD, Objects and ImportedSchemas using the Microsoft.MSE.Catalog.Module.Business.SchemaManager.GetSchemaByNamespace method.

Is there a recommended way to do schema retrieval, keeping in mind that an operation can have multiple versions (essentially, a schema can vary from version to version)?

Jul 15, 2009 at 4:34 PM
Edited Jul 15, 2009 at 4:36 PM

Thanks to latenightcoder I'm now successfully retreiving the endpoint schemas from the MSE Repository for schema validation however I've run into a new issue and was looking for some help.  When you import the Webservice Metadata to add the operation to the MSE Admin Tool the custom base types defined on the service schema are not automatically imported into the MSE Repository.

An example of the custom base types utilized in the origional service xsd would be as follows:

<xs:complexType name="Contact">


    <xs:element minOccurs="1" maxOccurs="1" name="FirstName" type="String50" />



<xs:simpleType name="String50">

  <xs:restriction base="xs:string">

    <xs:maxLength value="50" />




So, in the original schema validation within the service itself, a schema validation error would have been thrown if someone submitted a request with a FirstName element value of greater than 50 characters.


However, when the service operation is imported into MSE the custom type "Contact" now looks like this in the Repository:

<xs:complexType name="Contact">


    <xs:element minOccurs="1" maxOccurs="1" name="FirstName" type="xs:String" />




Notice the maximum length rule is lost...

I would like to know if there is anyway I can import the operation and keep those custom types that define maximum lengths?  Or, after the service operation has been imported is there a way to import a schema into MSE and use the full imported schema and all of its custom base types for the operation instead of what was imported along with the service operation?


Jul 15, 2009 at 6:55 PM

WSDL import should not remove any schema types. Can you post the WSDL so that I can confirm the issue.

Jul 15, 2009 at 7:24 PM
Edited Jul 15, 2009 at 9:19 PM


Forgive my lack of clarity in my previous posting.  My issue is that those special types like the String50 type is not actually published by the wsdl to the service that I'm trying to virtualize and that is why they are not imported.  Those custom types like String50 were not imported from the original schema that the service was generated from using Guidence Automation.  So my real problem is that I need to somehow get my original schema, and not the one published by the service wsdl, imported into MSE and reference that schema on the operation.  Is there a way to do this?

I realize I could potentially add all of those custom base types individually to the Data Entites and then manage dependencies to those types in Manage Service Model Components > Data Entites however we are talking a lot of custom base types not provided by the original service wsdl (100+) and to add every one and change every dependency independently would take a considerable amount of time and I'm on a strict time constraint.

Jul 20, 2009 at 6:58 PM


Jul 20, 2009 at 10:25 PM

Perhaps I'm missing something, but if you have the original schema you could go to the Data Entity Management layout, right click on the Schema's view and select the option to add a new schema.  You could then paste your schema definition into the XmlContent field and then click Apply to load the schema into the MSE.  This will cause your schema to be parsed into the various data elements which you could then reference from your operations and resources as needed.  The only tweak you might need would be to add the appropriate "wrapping" entities to your schema to model the request/response messages.