目前我找不到任何官方信息,根据经验,如果您的 XML 格式错误,则会收到 400 HTTP,如果 SOAP 消息中存在某种不正确的值,则会收到 SOAP 错误消息。
要记住的一点是 HTTP 是 SOAP 服务使用的一种协议。如果需要,您可以通过 STMP(电子邮件)或其他协议运行 SOAP 服务。 HTTP 仅仅是传输。因此,不需要在标准文档中包含这些特定的 HTTP。 SOAP 术语中的 HTTP 400 意味着无法传递非常糟糕的消息。
例如,像下面这样的格式错误的 xml 应该给出 HTTP 400:
<nonsense> <!-- opening tag with no closing tag-->
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ecol="http://www.blahblahablha">
<soapenv:Header/>
<soapenv:Body>
<ecol:GetDatabaseConnectionInfo/>
</soapenv:Body>
</soapenv:Envelope>
在下面的示例中,我的消息有一个 GUID,其值为 ?,这是一个错误,但是由于 XML 格式正确,因此消息在 SOAP 错误消息中返回。
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ec="http://www.blahablha.au/foo" xmlns:irix="http://www.blahblah/IRIX_Headers_V1" xmlns:irix1="http://schemas.datacontract.org/2004/07/IRIXContract.MsgHeaderBase">
<soapenv:Header/>
<soapenv:Body>
<ec:GetAccountActiveArrangement>
<ec:GetAccountActiveArrangementReq>
<irix:MsgReqHdr>
<!--Optional:-->
<irix:MsgGUID>?</irix:MsgGUID>
<!--Optional:-->
<irix:MsgDateTime>?</irix:MsgDateTime>
<!--Optional:-->
<irix:SecCredInfo>
<!--Optional:-->
<irix:IRIXUserID>?</irix:IRIXUserID>
<!--Optional:-->
<irix:IRIXPassword>?</irix:IRIXPassword>
<!--Optional:-->
<irix:AuthToken>?</irix:AuthToken>
<!--Optional:-->
<irix:ConsumerSystemID>?</irix:ConsumerSystemID>
</irix:SecCredInfo>
</irix:MsgReqHdr>
<ec:accountNumber>70001</ecol:accountNumber>
</ec:GetAccountActiveArrangement>
</soapenv:Body>
</soapenv:Envelope>
发送这个会导致以下错误:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<s:Fault>
<faultcode xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher">a:DeserializationFailed</faultcode>
<faultstring xml:lang="en-AU">The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://www.blah blah/ECollNXDB_V1:GetAccountActiveArrangementReq. The InnerException message was 'There was an error deserializing the object of type IRIXNXSoapServices.Message.Operations.Account.Get.GetAccountActiveArrangementReqV1. The value '?' cannot be parsed as the type 'Guid'.'. Please see InnerException for more details.</faultstring>
<detail>
<ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<HelpLink i:nil="true"/>
<InnerException>
<HelpLink i:nil="true"/>
<InnerException>
<HelpLink i:nil="true"/>
<InnerException>
<HelpLink i:nil="true"/>
<InnerException i:nil="true"/>
<Message>Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).</Message>
这是标准行为。