Calling JSON web service with parameters - Objective C - iOS

后端 未结 3 1648
南方客
南方客 2021-02-08 20:40

I\'m trying to call a simple JSON webservice with a parameter in objective c. Doesn\'t work so far.

Here is the web service method:

[WebMethod]
[ScriptMe         


        
相关标签:
3条回答
  • 2021-02-08 21:18

    in the node <system.web> of web.config add the next lines:

    <webServices>
          <protocols>
           <add name="HttpPost"/>
          </protocols>
    </webServices>
    

    http://support.microsoft.com/default.aspx?scid=kb;en-us;819267

    0 讨论(0)
  • 2021-02-08 21:19

    For the iOS part,

    Your code looks OK. There should be no problem on the client side. But you can do the following debuggings;

    • Just before you call sendSynchronousRequest:returningResponse:error insert a breakpoint and check if your jsonData is valid. Because you are not checking the error you assigned for JSON Serialization.
    • If there is no problem with your JSON data, find another basic JSON server and try consuming it. If your client-side works, you will know there is something wrong on your server-side.

    Cheers

    0 讨论(0)
  • 2021-02-08 21:26

    I had a similar problem. I was setting the HTML body with jsonData as you do and it didn't work. It turned out that the JSON service wasn't configured as it was supposed to be.

    So, instead of setting the HTML body, try calling the URL like a GET method.

    I mean, remove the lines that you set the HTML body, and change the URL to

    http://localhost:8080/ListrWS.asmx/LogIn?username=usernameTest&password=passwordTest
    

    Don't change the method (POST).

    If this works, you will have to do some work on the server side.

    0 讨论(0)
提交回复
热议问题