BizTalk SOAP Web Publishing Wizard does not properly sets the min and max occurs properties

“If you publish a schema that contains minOccurs or maxOccurs attributes with specific values, these values may be different in schema exposed by the published Web service. As a general rule of thumb, all minOccurs attributes are converted to 0 (minOccurs=0) and maxOccurs attributes are converted to either 1 or unbounded (maxOccurs=1 or maxOccurs=unbounded)”

See the section “Publishing schemas that specify values for minOccurs or maxOccurs attributes” in the online BizTalk documentation  Considerations When Publishing Web Services to read the official statement.

OK, Right… but it is not exactly occurring like that:

in the Source schema, if the element type is int and minOccurs is =1 , the web services publishing wizard works fine:  the same value can be found in the final Wsdl

However,

in the Source schema, if the element type is string and minOccurs is =1 , the web services publishing wizzard does not works and changes minOccurs  to 0 (no matter what the original value is)

How To Fix it

Move to WCF!!!!!   and this will not happen!    ;-)

but if you can not move to WCF, then:

Edit the  DataType.cs file, locate the field having the problem and change the attribute definition by adding the IsNullable = true modifier.

[System.Xml.Serialization.XmlElementAttribute(IsNullable = true,Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]

This procedure will ensure properties are generated fine each time the wsdl is generated.

Where is the DataType.cs file located?

The wizard serializes the XSD files in the DataType.cs file and place it under the virtual directory assigned to the web service already created.

Warning

Take care when executing the SOAP Web Services Publishing Wizard again since it will replace all the custom changes made.