Manually editing BizTalk wcf-adapter schema
I am new to generating schemas in the way I am doing it now (Manually) and sort of need some help here please. I have a schema, as below, that I am not sure is even correct. What I want is a Customer record that can c开发者_如何转开发ontain more than one Address record. What I have below does not seem correct, or is it? I am referring in particular to where I have the MAXOCCURS=UNBOUNDED applied. How do you think I ought to do this instead? Thanks in advance
**
<xs:element name="Customer">
<xs:complexType>
<xs:sequence>
<xs:element name="CustomerCode" type="xs:string" />
<xs:element name="Name" type="xs:string" />
<xs:element name="Active" type="xs:int" />
<xs:element name="SubNumber" type="xs:string" />
<xs:element name="CustomerAccountNumber" type="xs:string" />
<xs:element name="AccountBranchCode" type="xs:string" />
<xs:element name="BranchLocationCode" type="xs:string" />
<xs:element name="Attention" type="xs:string" />
<xs:element maxOccurs="unbounded" name="Addresses">
<xs:complexType>
<xs:sequence>
<xs:element name="Street1" type="xs:string" />
<xs:element name="Street2" type="xs:string" />
<xs:element name="City" type="xs:string" />
<xs:element name="State" type="xs:string" />
<xs:element name="Zip" type="xs:string" />
<xs:element name="Country" type="xs:string" />
<xs:element name="Description" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element maxOccurs="unbounded" name="PhoneNumbers">
<xs:complexType>
<xs:sequence>
<xs:element name="PhoneNumber" type="xs:string" />
<xs:element name="PhoneType" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
**
What you have there looks correct, although I would rename the 'Addresses' and 'PhoneNumbers' elements to 'Address' and 'PhoneNumber' respectively. This would imply XML like the following:
<Customer>
<CustomerCode>1234</CustomerCode>
<Name>Customer</Name>
...
<Address>
...
</Address>
<Address>
...
</Address>
<PhoneNumber>
...
</PhoneNumber>
<PhoneNumber>
...
</PhoneNumber>
</Customer>
Alternatively, you may want to wrap your repeating Address and PhoneNumber elements in Addresses and PhoneNumbers - this often makes life easier if you're attempting to map to WCF DataContracts:
<xs:element name="Addresses">
<xs:complexType>
<xs:sequence>
<xs:element name="Address" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="Street1" type="xs:string" />
<xs:element name="Street2" type="xs:string" />
<xs:element name="City" type="xs:string" />
<xs:element name="State" type="xs:string" />
<xs:element name="Zip" type="xs:string" />
<xs:element name="Country" type="xs:string" />
<xs:element name="Description" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
This will give you something like:
<Customer>
<CustomerCode>1234</CustomerCode>
<Name>Customer</Name>
...
<Addresses>
<Address>
...
</Address>
<Address>
...
</Address>
</Addresses>
<PhoneNumbers>
<PhoneNumber>
...
</PhoneNumber>
<PhoneNumber>
...
</PhoneNumber>
</PhoneNumbers>
</Customer>
精彩评论