minOccurs from VB code - attribute?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



In a VB.Net webservice, after adding a data class, members of type String
get a "minOccurs=0" attribute in the generated WSDL.

Is there an attribute you can apply to the definition, or some other way to
turn this into "minOccurs=1"?


For example, in this class:

<WebService(Namespace:=...)> _
public class MyWebService
Inherits System.Web.Services.WebService

<WebMethod()> Public Sub TestFunc(byval t as TestData)
....
End Sub

public class TestData
Public Name as string
end class

end class

the "Name" member of TestData comes out in WSDL as

<s:element minOccurs="0" maxOccurs="1" name="Name" type="s:string" />


I'd like to get minOccurs="1" instead, so clients can understand that the
value isn't optional.

I've tried playing around with the IsNullable attribute through
SystemXml.Serialization.XmlElementAttribute and
System.Xml.Serialization.SoapElement, but it makes no difference.
.



Relevant Pages