10

I've been trying to get a webservices working using Sudzc. Whenever I convert my WSDL to obj-c without automatic reference counting it works just fine. The problem is, we are building all our applications in iOS 5 now and all our code uses ARC. Sudzc now also allows you to create a bundle with ARC enabled but when I run this code it always returns null.

I tried debugging the Sudzc code and it does receive a correct xml response back from the service. Somewhere something is lost in translation. I tried converting the working Sudzc code without ARC into code with ARC enabled but as soon as I've fixed all errors it returns null again.

Did anyone encounter this and know what is going wrong? Would save me loads of time not having to debug the whole Sudzc code by myself.

Brad Larson
  • 170,088
  • 45
  • 397
  • 571
Twan
  • 155
  • 3
  • 7
  • As always 12 minutes after finding the courage to post a question I found the solution. Flagged the Sudzc classes with -no-objc-arc and now I can use the old working code. As a fairly new user of obj-c I didn't know that existed.. – Twan Dec 27 '11 at 14:38
  • I'm experiencing the same problem and is probably a newer user than you :) I honestly don't know what you mean with flagging with -no-objc-arc, can you explain this? –  Dec 30 '11 at 10:30
  • Consider posting that as an answer and mark it accepted so that this question will be considered solved. While you're at it you may want to address @Stefan Jansson's comment as well. – BoltClock Dec 30 '11 at 11:08

4 Answers4

16

In my case (SUDZC with ARC for IOS), I have replaced the folowing code in SoapRequest.m file;

CXMLNode* element = [[Soap getNode: [doc rootElement] withName:@"Body"] childAtIndex:0];

with

CXMLNode* element = [[Soap getNode: [doc rootElement] withName:@"soap:Body"] childAtIndex:0];

Somehow the respective function is searching for the root element with name "Body". After inspecting the soap envelope it is easy to see the root element's name is "soap:Body".

ilyasd
  • 269
  • 3
  • 9
  • 3
    THANK YOU THANK YOU THANK YOU! I was stuck on this same issue for two days and this was the fix I needed. – Unknown Coder Jan 14 '12 at 21:45
  • Thanks. Also, if this ilyasd's doesn't work, try `@"soapenv:Body"` instead of `@"soap:Body"`. – inket Feb 17 '12 at 11:24
  • Just had the same problem, and the above fix solved the issue :) – DNRN Jun 02 '12 at 10:23
  • 1
    FYI, this will only work if the actual namespace is "soap", it is perfectly legal for it to be something else so long as it is properly declared in the XML document. Eg, you could have `` which would need `@"s:Body"` or `` which would be just `@"Body"`. – tvon Feb 21 '13 at 15:52
  • One more thing, the SoapFault handling fails for the same lack of namespace support. – tvon Mar 20 '13 at 12:21
1

My webService was create in Java with Axis Eclipse.

FOR ARC I use : "soapenv:Body"

And in the file SoapObject.m I add

#import "Soap.h"
#import "SoapObject.h"
Anthone
  • 2,156
  • 21
  • 26
0

In my case "env:Body" worked. Check your return xml (by printing) and replace appropriately

0

In my case it was an .Net web service (WCF) and I had to use s:Body: Found out by printing the CXML document:

CXMLNode* test = [doc rootElement];
NSLog(@"%@",test);

Here I got this:

<CXMLElement 0x68c1a50 [0x68c1b10] s:Envelope <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><**s:Body**><GetUserIDResponse xmlns="http://tempuri.org/"><GetUserIDResult>8</GetUserIDResult></GetUserIDResponse></s:Body></s:Envelope>>

Thanks to previous posts I was able to find it out and posted the complete answer again on my blog: http://www.dailycode.info/Blog/post/2012/08/07/SUDZC-webservices-always-return-0-(WCF-web-service-and-IOS-client).aspx

Mark
  • 379
  • 3
  • 7