locked
parsing xml schema RRS feed

  • Question

  • User-309816304 posted

    HI all,

    i have a wsdl which is splitted intlo multiple schemas.

    lets suppose in main wsdl in WSDL:types i have below code snippe

    <wsdl:types>

    <xsd:schema targetNamespace="http://tempuri.org/Imports">

    <xsd:import schemaLocation="http://localhost:8787/service/test?xsd=xsd0" namespace="http://tempuri.org/"/>

    <xsd:import schemaLocation="http://localhost:8787/service/test?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/"/

    <xsd:import schemaLocation="http://localhost:8787/service/test?xsd=xsd2" namespace="http://schemas.datacontract.org/2004/07/TestService"/><xsd:import schemaLocation="http://localhost:8787/service/test?xsd=xsd3" namespace="http://othernamespace.org/"/>

    </xsd:schema>

    </wsdl:types>

    and if i go to schemalocation  "http://localhost:8787/service/test?xsd=xsd0" i have below code in the schema element as given below

    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://tempuri.org/" elementFormDefault="qualified" targetNamespace="http://tempuri.org/"><xs:import schemaLocation="http://localhost:8787/service/test?xsd=xsd2" namespace="http://schemas.datacontract.org/2004/07/TestService"/><xs:import schemaLocation="http://localhost:8787/service/test?xsd=xsd3" namespace="http://othernamespace.org/"/></div> <div class="line">

    if i again deep down to location "http://localhost:8787/service/test?xsd=xsd2"

    like this i have recursive imports how can i parse the xsd files and get the information regarding schema

    Wednesday, September 17, 2014 1:51 AM

All replies

  • User-484054684 posted

    If you add a web reference of the wsdl for any client application (console app or website or windows form app), then, you should be able to see all the imported xsd in client application from Solution Explorer (probably in References folder). You can click Show All files/folders if that doesn't appear in website projects.

    Wednesday, September 17, 2014 1:26 PM
  • User-309816304 posted

    Hi ,

    i need to parse the information.using c#.

    Friday, September 19, 2014 7:55 AM
  • User-484054684 posted

    Could you elaborate what do you mean by parsing the xsd - are you trying to hold this information in some C# class objects? If so, could you post some snippet which you are trying to achieve and the error you are getting in the approach. That would help us understand your issue better.

    Friday, September 19, 2014 8:04 AM
  • User-309816304 posted

    ya i am holding the information in the c# objects and here is the below code snippet.

    private void parseSchema(Uri e)
    {

    XmlReader reader = XmlReader.Create(e.ToString());
    XmlSchema schema = XmlSchema.Read(reader, ValidationCallBack);

    TargetSchemaSet.Add(schema );
    putElementsIntoSchema(schema );
    foreach (System.Xml.Schema.XmlSchemaObject externalSchema in schema.Includes)
    {
    if (externalSchema is System.Xml.Schema.XmlSchemaImport)
    {
    Uri baseUri = new Uri(tempSourceUri.ToString());
    Uri schemaUri = new Uri(baseUri, ((System.Xml.Schema.XmlSchemaExternal)externalSchema).SchemaLocation);
    parseSchema(schemaUri);

    }

    }
    }
    }

    this is the way i am doing recursion over schemas.i am not able to parse xsd files and the error is "there is error in the xml document 1,40".

    but the xml document is good and this WSDL is working fine in SOAPUI. just look at the code and tell me where i am going wrong.

    thanks

    Monday, September 22, 2014 1:45 AM