By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,745 Members | 812 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,745 IT Pros & Developers. It's quick & easy.

Schema in WSDL File

P: n/a
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.
Oct 11 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"SteveChamp" <St********@discussions.microsoft.comwrote in message
news:ED**********************************@microsof t.com...
>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?
Steve,

The WSDL is only generated automatically if you allow it to be. If you use:

<webServices>
<protocols>
<remove name="Documentation"></remove>
</protocols>
</webServices>

in your web.config, then service.asmx?WSDL will not return a generated WSDL.
You can then host your WSDL wherever you like, or not at all.

As to the minOccurs="0", this is only a guess, but, as a reference type,
your string could be ommitted by returning null. In terms of XML Schema,
null is not a valid string. One way to represent it would be for it to be
absent entirely.

John
Oct 11 '06 #2

P: n/a
John,

Thanks very much for the info. I may end up having to build my own WSDL from
scratch.

Steve C.
Oct 11 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.