0

Could anybody clarify the process of consuming aspx webservices in iOS? I have already tried JSON framework but now, need to create an app that consumes .net webservices in XML format. I need both to post some data to, and get data from the server. I already read about existing XML parsers for iOS that I found (here)

The question is do I need to do additional setup, like wrapping my query strings in SOAP or smth, in order to communicate with webserver? Would it be sufficient to use only one of mentioned libraries in the link or do I need additional stuff?

UPDATE: I found one tutorial on web (here) that demonstrates how to consume web services using Json-framework. Also, I found another one that demonstrates it using NSXMLParser (here). I'm not not very familiar with WSDL and SOAP, so any detailed explanation on how to implement would be desirable :). In both of these examples you just have to construct a request string in xml format and execute it, and that's it. Both examples actually bypasses the heavyness of SOAP and WSDL, so I was wondering do I have to know and do more that just construct a request string, execute it and get response?

Centurion
  • 14,106
  • 31
  • 105
  • 197
  • this link will be of your help http://stackoverflow.com/questions/204465/how-to-access-soap-services-from-iphone – Girish Kolari Aug 24 '11 at 17:54
  • 1
    There isn't any such thing as an "aspx webservice". You mean SOAP, right? – Dan Diplo Aug 24 '11 at 18:58
  • Yep. My current task involves posting and getting some info to asmx webservice. The webservice uses SOAP XML format for communication. So I was wondering what library should I use to construct post/get request string and then how to get response in the same manner. – Centurion Aug 24 '11 at 19:15

1 Answers1

2

While wsdl2objc is out there (as noted by @Girish Kolari), the truth is that there's no easy answer. I've never successfully gotten wsdl2objc working well for something that I couldn't have done more easily by hand. You will need to learn SOAP and WSDL. That's just a fact of life if you can't get access to a REST interface. In my experience, your best bet for simple SOAP access is to do it by hand, and your best bet for somewhat complicated SOAP access is gSOAP. Your best bet for very complicated access is to redesign something so it's not so complicated, ideally in REST. SOAP is a giant pain that some languages (C#) shield you from. ObjC does not shield you from it, so it continues to be a giant pain.

Yes, SOAP leaves a bad taste in my mouth.

Rob Napier
  • 286,113
  • 34
  • 456
  • 610
  • Thanks for consolation. I didn't got specs about exact exchange format with those webservices. Currently, I just know that they are accessible as asmx, I mean .net webservices. After doing some googling I came across to ambiguous blogs where one of them stated that you need SOAP for performing post/get requests, and the others links that I quoted in the question just state that it would be sufficient to construct those requests by hand using some libraries. – Centurion Aug 25 '11 at 00:08
  • So, from your answer, I understood that SOAP might be not mandatory if the webservice does not require to use SOAP XML format for posting and getting messages. So, I guess those two links with examples how to consume .NET webservice using Json-framework, NSXMLParser might be suitable for me if the webservice would be constructed in simple way (REST or simple SOAP). Until I will get actual specs, how can I distinguish what is the current format for those webservices? I need to perform the same actions as some current website does. I saw that i performs asmx request, what else should I check? – Centurion Aug 25 '11 at 00:15
  • I believe all ASMX services are SOAP-based. But remember, SOAP is just an XML protocol over HTTP. As long as it's not too complicated (using WS-Security for instance), you can often hand-write the outgoing XML and hand-parse the incoming XML (with NSMXLParser or any of the other parsers). The best way to find out without a spec is to look at the traffic from an existing client. – Rob Napier Aug 25 '11 at 13:31