I have a web service with a single web method:
[WebMethod]
public string SendInt([XmlElement(IsNullable=false)] int someInt)
{
return "Hello World";
}
The WSDL generated by this web method includes the following lines:
<s:element name="SendInt">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="someInt" type="s:int"/>
</s:sequence>
</s:complexType>
</s:element>
The WSDL clearly states that the request parameter is a value type (int) with a minOccurs=1 but when I am using SoapUI to send the following request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
<soapenv:Header/>
<soapenv:Body>
<tem:SendInt>
</tem:SendInt>
</soapenv:Body>
</soapenv:Envelope>
I am getting a valid response from the server, instead of an error indicating that someInt parameter is missing.
In the server i can see that a 0 value is assigned to the someInt parameter.
Is this the normal behavior?
If so, how can I know in my web method if the user sent a 0 value or simply forgot to send this parameter?
If it is not a normal behavior how can I fix it?
Hey as you are specifying the element in the request it is there you just did not assign a value to it. The default value of int is 0 so yes this is normal behaviour. If you leave out the element you will get an invalid request. If they forgot to send this parameter then probably the whole element would not be present right. In that case the webservice would throw an error