0

I had a very strange situation in using web service

Here is my Xcode Project File https://dl.dropbox.com/u/9507586/FubonTest.zip

I got the response back from the server as below.

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)

I did receive bytes, but the xml tag file is null. The server side people told me they use utf-8 encoding, but it just returned null. If I use ascii encoding, the returning data is not null, but it's not the xml tag file I expected.

The correct returning xml tag files should be as below. The returning xml tag file is using eclipse(window version) web service function.

<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>

Can someone help me to sort it out?

Lee
  • 25
  • 7
  • Could you post some relevent code? Probably where you get the data from the response, it is unlikely anyone will wade through an entire project. – Mike D Mar 05 '13 at 02:30

1 Answers1

1

There is a misspelling. In your ViewController.m file, line 57:

Change forHTTPHeaderField: @"Contnet-Type"];

to forHTTPHeaderField: @"Content-Type"];

tolgamorf
  • 809
  • 6
  • 23
  • Thanks for your good eyesights. I did get the response. However, it seems the response data is using hex. 该用户未投保 – Lee Mar 05 '13 at 03:15
  • 该用户未投保 – Lee Mar 05 '13 at 03:16
  • How to convert the utf-8 data into the string data as the comment above since I used NSUTF8StringEncoding in the code already? – Lee Mar 05 '13 at 03:44
  • I am not sure, but maybe [this](http://stackoverflow.com/a/8114488/1576979) will help. – tolgamorf Mar 05 '13 at 04:33
  • Finally, I used NSXMLParser Delegate Method foundCharacter and it just works, automatically converted to the string, so strange. – Lee Mar 05 '13 at 08:43