【问题标题】:Web service return only XMLWeb 服务仅返回 XML
【发布时间】:2012-08-30 23:05:24
【问题描述】:

我正在使用服务参考使用 Web 服务。

我使用 ToString() 转换了结果返回。

using (ConnectClient client = new ConnectClient("ESConnect"))
                {
                    result = client.actiService("ssss", "sss", "sss").ToString();

我使用 xml.linq 来读取 xml。

using (XmlReader reader = XmlReader.Create(new StringReader(result)))

我收到以下错误:

The content type text/plain of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly.    

编辑:

Web 服务是使用 Apache Axis SOAP 创建的。

【问题讨论】:

  • 请添加actiService方法代码
  • 在“结果”行添加一个断点并检查从服务中传入的内容。似乎它没有返回格式良好的 xml。
  • 它确实返回了一个有效的 xml,但可能标头没有告诉它是一个 xml?
  • 我不能提供actiService代码,因为它是第三方解决方案。

标签: c# linq-to-xml axis


【解决方案1】:

如果你只是解析一个 XML 字符串,你可以试试XDocument.Load

【讨论】:

  • 是的,我正在使用它 XDocument doc = XDocument.Load(reader, LoadOptions.SetLineInfo);
  • XDocument 和 XmlDocument 类不一样。您在 XDocument.Load 中看到的错误是什么?
猜你喜欢
  • 2012-04-05
  • 1970-01-01
  • 1970-01-01
  • 2011-05-05
  • 1970-01-01
  • 2011-03-01
  • 1970-01-01
  • 2023-03-22
  • 1970-01-01
相关资源
最近更新 更多