Hi,

I am trying to validate a XML document using remote XSD and saxon.Net 9.2. Though the credentials to access the remote server is set, the SchemaManager.Compile(XmlReader) is returning the following error message: net.sf.saxon.type.SchemaException: net.sf.saxon.trans.XPathException: javax.xml.transform.TransformerException: The remote server returned an error: (401) Unauthorized.

The C# code snippet is given below. For info, Saxon API is registered on the GAC and the Saxon home directory has been set. At the moment, I am using evaluation version. On successful validation and with satisfactory performance, I would like to buy the licensed version.

Please help.

Thanks

Jawahar

Processor processor = new Processor(true);

      SchemaManager manager = processor.SchemaManager;

      manager.ErrorList = new ArrayList();

      XmlReaderSettings schemaReaderSettings = new XmlReaderSettings();

      XmlUrlResolver resolver = new XmlUrlResolver();

      resolver.Credentials = new NetworkCredential(<UserName to access the remote server>,<Password to access the remote server>);

      schemaReaderSettings.XmlResolver = resolver;

      XmlReader schemaReader = XmlReader.Create(<remote http path to xsd file>, schemaReaderSettings);

     

      try

      {

        // Note: Visual studio debug watch indicates that the instance schemaReader.Settings.XmlResolve.Credentials is Null,

}

      catch (Exception e)

      {

        Console.WriteLine(e);

        Console.WriteLine("Schema compilation failed with " + manager.ErrorList.Count + " errors");

        foreach (StaticError error in manager.ErrorList)

        {

          Console.WriteLine("At line " + error.LineNumber + ": " + error.Message);

        }

        Console.ReadLine();

        return;

      }


      // Use this to validate an instance document

      SchemaValidator validator = manager.NewSchemaValidator();

      Uri instanceUri = new Uri(<Local source xml file to validate>);

      validator.SetSource(instanceUri);

      validator.ErrorList = new ArrayList();

      XdmDestination psvi = new XdmDestination();

      validator.SetDestination(psvi);

      try

      {

        validator.Run();

      }

      catch (Exception e)

      {

        Console.WriteLine(e);

        Console.WriteLine("Instance validation failed with " + validator.ErrorList.Count + " errors");

        foreach (StaticError error in validator.ErrorList)

        {

          Console.WriteLine("At line " + error.LineNumber + ": " + error.Message);

        }

        return;

      }

***********************************************************************************************

This email, including any attachment, is confidential and may be legally privileged. If you are not the intended recipient or if you have received this email in error, please inform the sender immediately by reply and delete all copies from your system. Do not retain, copy, disclose, distribute or otherwise use any of its contents.

 

Whilst we have taken reasonable precautions to ensure that this email has been swept for computer viruses, we cannot guarantee that this email does not contain such material and we therefore advise you to carry out your own virus checks. We do not accept liability for any damage or losses sustained as a result of such material.

 

Please note that incoming and outgoing email communications passing through our IT systems may be monitored and/or intercepted by us solely to determine whether the content is business related and compliant with company standards.

***********************************************************************************************

The Stationery Office Limited is registered in England No. 3049649 at 10 Eastbourne Terrace, London, W2 6LG