WCF 错误 - 接收对 http://localhost:50750/*********.svc 的 HTTP 响应时出错
WCF Error - An error occurred while receiving the HTTP response to http://localhost:50750/*******.svc
我在调试时收到以下错误。
An error occurred while receiving the HTTP response to http://localhost:50750/FIGService.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.
现在我看到很多帖子都出现了这个错误,我已经将我的 WCF 缩减到绝对准系统,但我仍然遇到错误,我 运行 正在执行以下操作:
Public Function TestXML(ByVal Username As String, ByVal Password As String, ByVal XML As String) As XmlDocument Implements FreshCloud.TestXML
Dim ReturnXMLDoc As New XmlDocument()
If ValidateLogin(Username, Password) <> False Then
ReturnString = "<FreshLead><Result><Message>Failed - XSD Validation</Message><DateTime>" & Date.Now.ToString & "</DateTime></Result></FreshLead>"
ReturnXMLDoc.LoadXml(ReturnString)
Return ReturnXMLDoc
End If
End Function
不用担心代码的无用性,我只是将各种位复制并粘贴到 运行 测试中,这比 运行 带有按钮的简单测试应用要好:
Dim client As FreshCloudClient = New FreshCloudClient()
Dim strXML = client.TestXML("ABC", "BS", "Doesn't Matter")
Dim strTest = strXML
client.Close()
我刚刚 return 收到上面的错误,请任何可以阐明的东西将不胜感激这是一个大项目,我不得不深入研究微软的模糊错误消息帮助一个学习者。
干杯! :)
更新
在挖掘 WCF 的日志后,我偶然发现了这个:
Type 'System.Xml.XmlDocument' is an invalid collection type since it does not have a valid Add method with parameter of type 'System.Object'.
谁能告诉我为什么 WCF 会抛出这个异常?
干杯。
更新 2
好的,按照 Lerners 的建议,我现在得到了以下内容:
Public 函数测试XML(ByVal 用户名作为字符串,ByVal 密码作为字符串,ByVal XML 作为字符串)作为 XElement 实现 FreshCloud.TestXML
Dim ReturnXMLDoc
If ValidateLogin(Username, Password) <> False Then
ReturnString = "<FreshLead><Result><Message>Failed - XSD Validation</Message><DateTime>" & Date.Now.ToString & "</DateTime></Result></FreshLead>"
ReturnXMLDoc = XElement.Parse(ReturnString)
Return ReturnXMLDoc
End If
End Function
在我的客户端,有人说要将响应放在变量和 Console.WriteLine 变量上,它只是 returned System.Object?
当然这应该 return XML 当我在 WCF 端调试时 ReturnXMLDoc 变量中显示的那样?
更新 3
工作中!
Lerner 把我放在了正确的位置,我只需要从我的 'Client' 应用程序中更新服务定义。
干杯。
Return XElement 而不是 XDocument,XElement 是 IXmlSerializable。
var xml = XElement.Parse(ReturnString);
return xml;
我在调试时收到以下错误。
An error occurred while receiving the HTTP response to http://localhost:50750/FIGService.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.
现在我看到很多帖子都出现了这个错误,我已经将我的 WCF 缩减到绝对准系统,但我仍然遇到错误,我 运行 正在执行以下操作:
Public Function TestXML(ByVal Username As String, ByVal Password As String, ByVal XML As String) As XmlDocument Implements FreshCloud.TestXML
Dim ReturnXMLDoc As New XmlDocument()
If ValidateLogin(Username, Password) <> False Then
ReturnString = "<FreshLead><Result><Message>Failed - XSD Validation</Message><DateTime>" & Date.Now.ToString & "</DateTime></Result></FreshLead>"
ReturnXMLDoc.LoadXml(ReturnString)
Return ReturnXMLDoc
End If
End Function
不用担心代码的无用性,我只是将各种位复制并粘贴到 运行 测试中,这比 运行 带有按钮的简单测试应用要好:
Dim client As FreshCloudClient = New FreshCloudClient()
Dim strXML = client.TestXML("ABC", "BS", "Doesn't Matter")
Dim strTest = strXML
client.Close()
我刚刚 return 收到上面的错误,请任何可以阐明的东西将不胜感激这是一个大项目,我不得不深入研究微软的模糊错误消息帮助一个学习者。
干杯! :)
更新
在挖掘 WCF 的日志后,我偶然发现了这个:
Type 'System.Xml.XmlDocument' is an invalid collection type since it does not have a valid Add method with parameter of type 'System.Object'.
谁能告诉我为什么 WCF 会抛出这个异常?
干杯。
更新 2
好的,按照 Lerners 的建议,我现在得到了以下内容:
Public 函数测试XML(ByVal 用户名作为字符串,ByVal 密码作为字符串,ByVal XML 作为字符串)作为 XElement 实现 FreshCloud.TestXML
Dim ReturnXMLDoc
If ValidateLogin(Username, Password) <> False Then
ReturnString = "<FreshLead><Result><Message>Failed - XSD Validation</Message><DateTime>" & Date.Now.ToString & "</DateTime></Result></FreshLead>"
ReturnXMLDoc = XElement.Parse(ReturnString)
Return ReturnXMLDoc
End If
End Function
在我的客户端,有人说要将响应放在变量和 Console.WriteLine 变量上,它只是 returned System.Object?
当然这应该 return XML 当我在 WCF 端调试时 ReturnXMLDoc 变量中显示的那样?
更新 3
工作中!
Lerner 把我放在了正确的位置,我只需要从我的 'Client' 应用程序中更新服务定义。
干杯。
Return XElement 而不是 XDocument,XElement 是 IXmlSerializable。
var xml = XElement.Parse(ReturnString);
return xml;