2012-09-06 110 views
0

我正在使用服務引用來使用Web服務。僅限Web服務返回XML

我使用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.  

編輯:使用Apache Axis的SOAP創建

Web服務。

+0

http://stackoverflow.com/questions/5243929/wcf-service-client-the-content-type-text-html-charset- utf-8-of-the-response- – Habib

+0

請添加actiService方法代碼 –

+0

在「結果」行上添加一箇中斷點,並檢查從服務中進入的內容。似乎它沒有返回格式正確的XML。 – Deepesh

回答

0

如果你只是解析XML字符串,你可以嘗試XDocument.Load

+0

是的,我正在使用它XDocument doc = XDocument.Load(reader,LoadOptions.SetLineInfo); – Alvin

+0

XDocument和XmlDocument類不相同。 XDocument.Load看到的錯誤是什麼? – Echilon