views:

181

answers:

0

Validate a remote schema (http) with include schemas and specific proxy server settings

I can access the schemas on the other server via http, it resolves the include schemas (.xsd), no problem. I guess it uses the proxy server settings from Internet Explorer.

However, for this to work on other machines I need to be able to specify the proxy server (address and port) plus the credential (username and password). How to do this?

The only object I see with these settings is ServerXMLHTTP but I can't figure out how to use this with the XMLSchemaCache object.

Here's my code that works. How do I alter it to use explicit proxy server settings? Thanks!

  Dim docToValidate As MSXML2.DOMDocument60
  Dim docSchema As MSXML2.DOMDocument60
  Dim schemaCache As MSXML2.XMLSchemaCache60
  Dim myXml As String
  Dim namespace As String

  Const SCHEMA_URL As String = "http://../..xsd"

  Set docToValidate = New MSXML2.DOMDocument60

  docToValidate.resolveExternals = False
  docToValidate.preserveWhiteSpace = False
  docToValidate.setProperty "SelectionLanguage", "XPath"
  docToValidate.setProperty "MultipleErrorMessages", True

  myXml = "<...>"

  docToValidate.LoadXML myXml

  Set docSchema = New MSXML2.DOMDocument60

  docSchema.async = False
  docSchema.resolveExternals = True
  docSchema.Load SCHEMA_URL

  namespace = docSchema.DocumentElement.getAttribute("targetNamespace")

  Set schemaCache = New MSXML2.XMLSchemaCache60

  schemaCache.Add namespace, docSchema

  Set docToValidate.Schemas = schemaCache

  Dim parseErrors As IXMLDOMParseError2
  Set parseErrors = docToValidate.Validate()    
  ' Walk any errors...