Using the XSD.exe tool, I created a number of classes from my XSD file.
When I generate the WSDL for my web service, the schema does not have
the proper Occurance constraints for the attributes. In this example,
the MessageID element should always occur (minOccur=1, maxOccur=1), but
the WSDL generates minOccur=0. I can't pinpoint why this is happening
and I
can't find a may to force this in the code either. Anyone have any
insight? This is happening with a large number of elements, I just
provide one example below.
Code of the schema, classes, and WSDL excerpts below.
Thanks.
//********** Autogenerated Classes - Begin
<System.Xml.Serialization.XmlTypeAttribute([Namespace]:="BLS-DB")> _
Public Class MessageHeaderType
'<remarks/>
Public MessageID As MessageIDType
'<remarks/>
Public Acknowledgement As AcknowledgementType
End Class
<System.Xml.Serialization.XmlTypeAttribute([Namespace]:="BLS-DB")> _
Public Class MessageIDType
'<remarks/>
<System.Xml.Serialization.XmlElementAttribute(Data Type:="normalizedString")>
_
Public ID As String
'<remarks/>
Public Timestamp As Date
'<remarks/>
Public MessageType As MessageNameType
'<remarks/>
Public Sender As ParticipantType
End Class
//********** Autogenerated Classes - End
//************************************************** ************************
//********** Schema Excerpt - Begin
<?xml version="1.0" encoding="utf-8" ?>
- <definitions xmlns:s1="BLS-DB"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:s0="http://MY_WEBSERVER/schemas/BLS-DB.xsd"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
targetNamespace="BLS-DB"
xmlns="http://schemas.xmlsoap.org/wsdl/">
- <types>
- <s:schema elementFormDefault="qualified"
targetNamespace="http://4.21.130.175/schemas/BLS-DB.xsd">
<s:import namespace="BLS-DB" />
<!-- PORTION OF SCHEMA SNIPPED FOR CLARITY -->
<xsd:complexType name="MessageHeaderType">
<xsd:sequence>
<xsd:element name="MessageID" type="BLS-DB:MessageIDType"
minOccurs="1" maxOccurs="1"/>
<xsd:element name="Acknowledgement"
type="BLS-DB:AcknowledgementType" minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="MessageIDType">
<xsd:sequence>
<xsd:element name="ID" type="xsd:normalizedString" minOccurs="1"
maxOccurs="1"/>
<xsd:element name="Timestamp" type="xsd:dateTime" minOccurs="1"
maxOccurs="1"/>
<xsd:element name="MessageType" type="BLS-DB:MessageNameType"
minOccurs="1" maxOccurs="1"/>
<xsd:element name="Sender" type="BLS-DB:ParticipantType"
minOccurs="1" maxOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
//********** Schema File Excerpt - End
//************************************************** ************************
//********** WSDL Excerpt - Begin
- <s:complexType name="MessageHeaderType">
- <s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="MessageID"
type="s1:MessageIDType" />
<s:element minOccurs="0" maxOccurs="1" name="Acknowledgement"
type="s1:AcknowledgementType" />
</s:sequence>
</s:complexType>
- <s:complexType name="MessageIDType">
- <s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="ID"
type="s:normalizedString" />
<s:element minOccurs="1" maxOccurs="1" name="Timestamp"
type="s:dateTime" />
<s:element minOccurs="1" maxOccurs="1" name="MessageType"
type="s1:MessageNameType" />
<s:element minOccurs="1" maxOccurs="1" name="Sender"
type="s1:ParticipantType" />
</s:sequence>
</s:complexType>
//********** WSDL Excerpt - End