2013-03-05 85 views
0

我在使用Web服務Web服務接收空數據的iOS

有一個非常奇怪的情況這是我的Xcode項目文件 https://dl.dropbox.com/u/9507586/FubonTest.zip

我得到的迴應從下面的服務器返回。

2013-03-04 15:56:18.473 FubonTest[1059:f803] 1: connection: didReceiveResponse 
2013-03-04 15:56:18.473 FubonTest[1059:f803] 2: connection: didReceiveData 
2013-03-04 15:56:18.699 FubonTest[1059:f803] 2: connection: didReceiveData 
2013-03-04 15:56:18.699 FubonTest[1059:f803] 3: Done. Received Bytes: 1789 
2013-03-04 15:56:18.700 FubonTest[1059:f803] Return (null) 

我確實收到了字節,但是xml標籤文件爲空。服務器端的人告訴我他們使用utf-8編碼,但它只是返回null。如果我使用ascii編碼,返回的數據不是null,但它不是我期望的xml標籤文件。

正確的返回xml標籤文件應該如下。 返回的xml標記文件使用eclipse(窗口版本)Web服務函數。

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
<soapenv:Body> 
<ns1:RegistResponse xmlns:ns1="http://service.fubon.com" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> 
<RegistReturn xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="soapenc:string">該用戶未投保</RegistReturn> 
</ns1:RegistResponse> 
</soapenv:Body> 
</soapenv:Envelope> 

有人可以幫我整理一下嗎?

+0

你能發佈一些培訓相關的代碼?可能從響應中獲取數據的位置,不太可能有人會涉足整個項目。 – 2013-03-05 02:30:27

回答

1

拼寫錯誤。在你ViewController.m文件,第57行:

變化forHTTPHeaderField: @"Contnet-Type"];

forHTTPHeaderField: @"Content-Type"];

+0

謝謝您的好視力。我確實得到了迴應。但是,似乎響應數據使用十六進制。 &#x8BE5;&#x7528;&#x6237;&#x672A;&#x6295;& #x4FDD; Lee 2013-03-05 03:15:53

+0

&#x8BE5;&#x7528;&#x6237;&#x672A;&#x6295;&#x4FDD; – Lee 2013-03-05 03:16:21

+0

如何將UTF-8數據轉換爲字符串數據,因爲我已經在代碼中使用NSUTF8StringEncoding了? – Lee 2013-03-05 03:44:00