I have been experimenting with .Net web services for a while and have a few
questions about the schema in the automatically generated WSDL file, and
whether its content can be manipulated programatically.
First of all, I created several very simple test methods in my web service:
<WebMethod()_
Public Function TestString(ByVal test As String) As String
Return "The value passed was " + test
End Function
<WebMethod()_
Public Function TestInteger(ByVal test As Integer) As String
Return "The value passed was " + CStr(test)
End Function
When I look at the schema that was generated for these methods, I find the
following:
<s:element name="TestString">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="test" type="s:string"
/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="TestInteger">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="test" type="s:int" />
</s:sequence>
</s:complexType>
</s:element>
My question is - why did it specify a minOccurs of 0 for TestString, making
the argument optional, but specified a minOccurs of 1 for TestInteger? If a
method takes an argument, why is it making it optional for strings? Is it
possible to specify that a minOccurs of 1 should be used somewhere in code?
Also, if you want to validate against a custom schema type, say for a social
security number, how would you incorporate that into the automatically
generated WSDL file/schema? I read the article about customizing the
generation of service descriptions at
http://msdn2.microsoft.com/en-us/library/f9hatst6.aspx
but am not clear if the functionality they demonstrate can be used to do
what I want to do.
If it turns out that I cannot get what I want out of the automatically
generated WSDL/schema file, how could I then substitute my own file without
it being overwritten by the one being generated automatically?
Thanks,
Steve C.