我在调试时收到以下错误。
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()
我收到错误只是返回上述内容,请任何可以阐明的信息将不胜感激,这是一个大项目,我不得不认真研究微软模糊的错误消息对学习者没有帮助。
干杯! :)
更新
在深入研究 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
好的,根据勒纳的建议,我现在得到了以下结果:
公共(public)函数 TestXML(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 变量中,它只是返回 System.Object?
当我在 WCF 端进行调试时,这当然应该返回 ReturnXMLDoc 变量中显示的 XML 吗?
更新3
工作!
Lerner 让我处于正确的位置,我只需从我的“客户端”应用程序中更新服务定义即可。
干杯。
最佳答案
返回 XElement 而不是 XDocument,XElement 是 IXmlSerialized。
var xml = XElement.Parse(ReturnString);
return xml;
关于vb.net - WCF 错误 - 接收对 http ://localhost:50750/*******. svc 的 HTTP 响应时发生错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29771740/