471,123 Members | 855 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,123 software developers and data experts.

WSDL generates with wrong "minOccurs" values

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

Nov 12 '05 #1
2 6712
can you better explain what it is that you are doing,
and what you get,
and what you expect to get?

It seems you start with a WSDL that has minOccurs="1" and maxOccurs="1" on
some number of elements.
Then you generate VB code from that. Everything looks fine.
Then what? do you then generate WSDL from that (generated) VB code? and
that WSDL is the problem? if so, Why generate it? Why not use the
original WSDL ?

-D

<jo**********@yahoo.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com...
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

Nov 12 '05 #2
It seems pretty clear to me!
There is no .Net attribute for controlling the min/maxoccurs schema
attribute, is it?

So when you declare public fields that are reference types
and then generate a schema definition from the class definition you get all
these fields
with minoccurs="0" which means that they are optional.
It happens even for string fields which is quite rudiculus! I have a bunch
of classes
with string fields are not optionall at all.
How do you force the minoccurs=1 for thes type of fields?

"Dino Chiesa [Microsoft]" wrote:
can you better explain what it is that you are doing,
and what you get,
and what you expect to get?

It seems you start with a WSDL that has minOccurs="1" and maxOccurs="1" on
some number of elements.
Then you generate VB code from that. Everything looks fine.
Then what? do you then generate WSDL from that (generated) VB code? and
that WSDL is the problem? if so, Why generate it? Why not use the
original WSDL ?

-D

<jo**********@yahoo.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com...
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


Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Nick Caldwell | last post: by
reply views Thread by John Jenkins | last post: by
reply views Thread by John Jenkins | last post: by
reply views Thread by John Jenkins | last post: by
2 posts views Thread by NoNickname | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.