views:

162

answers:

1

I am trying to create an XML schema to use with the Web Service Software Factory. It's a fairly simple schema that is just a group of person objects. The (simplified) schema file looks like:

<?xml version="1.0" encoding="utf-8" ?> 
<xs:schema targetNamespace="http://tempuri.org/XMLSchema.xsd"
    elementFormDefault="qualified" 
    xmlns="http://tempuri.org/XMLSchema.xsd"
    xmlns:mstns="http://tempuri.org/XMLSchema.xsd"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;

    <xs:element name="Persons" type="PersonsType" />

    <xs:complexType name="PersonsType">
        <xs:sequence>
            <xs:element name="Person" type="PersonType" minOccurs="0"
                maxOccurs="unbounded" />
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="PersonType">
        <xs:all>
            <xs:element name="PersonName" type="xs:string" />
            <xs:element name="PersonAge" type="xs:integer" />
        </xs:all>
    </xs:complexType>

</xs:schema>

It's a simple collection of person elements with a parent element called Persons.

When I try to validate my .serviceContract file I get the error 'The file name 'Persons.xsd' is not compliant with the DataContactSerializer'.

Does anybody know how to fix this schema so that it will work with the Web Service Software Factory? And for bonus points, the next structure that I have to worry about will be a recursive list of corporations. Any suggestions about how to make recursive schemas that work with WSSF would be appreciated as well.

A: 

Did you already try to avoid named types?

<?xml version="1.0" encoding="utf-8" ?> 
<xs:schema targetNamespace="http://tempuri.org/XMLSchema.xsd"
  elementFormDefault="qualified" 
  xmlns="http://tempuri.org/XMLSchema.xsd"
  xmlns:mstns="http://tempuri.org/XMLSchema.xsd"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;

    <xs:element name="Persons">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="Person" minOccurs="0" maxOccurs="unbounded">
                    <xs:complexType>
                        <xs:all>
                            <xs:element name="PersonName" type="xs:string" />
                            <xs:element name="PersonAge" type="xs:integer" />
                        </xs:all>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
         </xs:complexType>
    </xs:element>

Also you may try to change <xs:all> to <sequence> in your <Person>.

Filburt
@fiburt: thanks for your help but I tried this and got "Type 'Person' in namespace 'http://tempuri.org/XMLSchema.xsd' cannot be imported. 'minOccurs' on the root sequence must be 1. Either change the schema so that the types can map to data contract types or use ImportXmlType or use a different serializer."
Jeff Hornby