我在本地主机上托管了一个肥皂网络服务,即使用Visual Studio的iis express。我正在使用SOAPUI发送它的值。如果我传递正确的值,它将起作用并进行调试。
但是如果我传递一个空标记或值,即如果期望一个日期时间,并且传递一个空标记,即,即使在命中webservices方法之前,它也会引发错误。
那么这是Web服务错误还是soapui错误?
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<soap:Code>
<soap:Value>soap:Sender</soap:Value>
</soap:Code>
<soap:Reason>
<soap:Text xml:lang="en">System.Web.Services.Protocols.SoapException: Server was unable to read request. ---> System.InvalidOperationException: There is an error in XML document (41, 34). ---> System.FormatException: String was not recognized as a valid DateTime.
at System.DateTimeParse.ParseExactMultiple(String s, String[] formats, DateTimeFormatInfo dtfi, DateTimeStyles style)
at System.DateTime.ParseExact(String s, String[] formats, IFormatProvider provider, DateTimeStyles style)
at System.Xml.Serialization.XmlCustomFormatter.ToDate(String value)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read3_Item(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read10_Item(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read11_DT_FunctionalLocation(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read12_SI_FunctionalLocation_In_Async()
at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer.Deserialize(XmlSerializationReader reader)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
--- End of inner exception stack trace ---
at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()</soap:Text>
</soap:Reason>
<soap:Detail/>
</soap:Fault>
</soap:Body>
</soap:Envelope>
我不会称其为webservice或soapUI错误:该服务正在按预期运行,并且拒绝了无效内容。
在定义您的Web服务的WSDL中将是一个XML架构,Web服务运行时环境可以根据该XML架构来验证传入的请求。如果请求未通过第一道防线,则没有意义将有效负载传递到您的服务。