SUDZC webservices always return 0 (WCF web service and IOS client)

by Mark Deraeve 7. August 2012 04:10

This occurs when you are using ARC (Automatic Reference Counting) generated code.

I found the place to look on these websites: 

and but it didn't solve my problem completely. 

In my case it was an .Net web service (WCF) and I had to use s:Body in stead of Body in the SUDZC generated file: SoapRequest.m

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

Found it out by NSLogging the CXML document (I used NSLog tp inspect the cxmldocument ):

        CXMLNode* test = [doc rootElement];



Here I got this:

<CXMLElement 0x68c1a50 [0x68c1b10] s:Envelope  <s:Envelope xmlns:s=""> <s:Body><GetUserIDResponse xmlns=""><GetUserIDResult>8</GetUserIDResult></GetUserIDResponse></s:Body> </s:Envelope> >


So if in your case the s:Body still doesn't do the trick, look into the XML code and find out which prefix to use! Soon I will be posting a complete solution using WCF web serivces and SUDZC generator for iOS 5. It will be a local service running on the local network, not available through the internet. 

Now an extra finding when you are working with custom objects. In my case I'm using Entity Framework with self tracking entities. There entities are passed over the WCF webservice. SUDZC will generate these objects for you and adds them to a NSMutableArray. But when you look at the objects in the array you will notice all properties are empty or nil. Therefore I had to make another change in the generated objects. In the exemple below I changed the generated code withName: @ChangeTracker ... into withName: @"a:ChangeTracker ... I had to change this for all the properties of the entity. So they were filled with the data coming from the xml!

NSMutableString* s = [superserializeElements];

[s appendFormat: @"<a:CashPayment>%@</a:CashPayment>", (self.CashPayment)?@"true":@"false"];

if (self.ChangeTracker != nil) [s appendString: [self.ChangeTrackerserialize: @"a:ChangeTracker"]];

if (self.City != nil) [s appendFormat: @"<a:City>%@</a:City>", [[self.CitystringByReplacingOccurrencesOfString:@"\""withString:@"&quot;" 


Be advised that when you start inserting or updating data, you will also need to change some generated code. You will need to add the namespace to the serialization code in the Soap.h and Soap.m file. The I created an extra method which will add the namespace to the envelope: 

// Creates the XML request for the SOAP envelope with optional SOAP headers and an extra given namespace.

+ (NSString*) createEnvelope: (NSString*) method forNamespace: (NSString*) ns withParameters: (NSArray*) params withHeaders: (NSDictionary*) headers  withExtraNameSpace: (NSString *) extraNameSpace;


Then in the Soap.m file we implement this method like this:


NSString* const SOAP_PREFIX = @"soapenv";

NSString* const NS_PREFIX = @"tem";

NSString* const SER_PREFIX_URL = @"xmlns:ser=\"\"";


NSString* const HTTP_PREFIX = @"http://";


// Creates the XML request for the SOAP envelope with optional SOAP headers.

+ (NSString*) createEnvelope: (NSString*) method forNamespace: (NSString*) ns

forParameters: (NSString*) params withHeaders: (NSDictionary*) headers withExtraNameSpace: (NSString *) extraNameSpace



    NSMutableString* s = [NSMutableStringstring];

    /* example header <soapenv:Envelope xmlns:soapenv="" xmlns:tem="" xmlns:ser="" xmlns:gal="">*/

    [s appendString: @"<?xml version=\"1.0\" encoding=\"utf-8\"?>"];


    [s appendString: @"<"];

    [s appendString: SOAP_PREFIX];

    [s appendString:@":Envelope xmlns:"];

    [s appendString: SOAP_PREFIX];

    [s appendString: @"=\"\" "];

    [s appendString:@" xmlns:"];

    [s appendString: NS_PREFIX];

    [s appendFormat:@"=\"%@\" ",ns ];

    [s appendFormat:@"%@ ",SER_PREFIX_URL];



        [s appendFormat:@" %@ >",extraNameSpace];



    if(headers != nil && headers.count > 0) {

        [s appendString: @"<"];

        [s appendString: SOAP_PREFIX];

        [s appendString:@":Header>"];


        for(id key in [headers allKeys]) {

            if([[headers objectForKey: key] isMemberOfClass: [SoapNil class]])


                [s appendFormat: @"<%@ xsi:nil=\"true\"/>", key];

            } else {

                [s appendString:[Soap serializeHeader:headers forKey:key]];



        [s appendString: @"</"];

        [s appendString: SOAP_PREFIX];

        [s appendString:@":Header>"];



    [s appendString: @"<"];

    [s appendString: SOAP_PREFIX];

    [s appendString:@":Body>"];


    NSMutableString* fullMethodName = [NSMutableStringstring];

    [fullMethodName appendString:NS_PREFIX];

    [fullMethodName appendString:@":"];

    [fullMethodName appendString:method];


    [s appendFormat: @"<%@>%@</%@>", fullMethodName,[params

                                                     stringByReplacingOccurrencesOfString:@"&" withString:@"&amp;"],




    [s appendString: @"</"];

    [s appendString: SOAP_PREFIX];

    [s appendString:@":Body>"];

    [s appendString: @"</"];

    [s appendString: SOAP_PREFIX];

    [s appendString:@":Envelope>"];

    return s;



So in this implementation you see there are more namespaces given. This I discovered after inspecting the WSDL xml and looking for the envelope structure. It could be that in your case the namespace prefix are different. Inspect this yourself.

Then when you call the insert function, just add the extra namespace to the create envelope:

NSString* _envelope = [SoapcreateEnvelope: @"InsertSomething"forNamespace: self.namespacewithParameters: _params withHeaders: self.headers  withExtraNameSpace:SOAP_FUNCTION_PREFIX];

The constant SOAP_FUNCTION_PREFIX looks like this: 

NSString* const SOAP_FUNCTION_PREFIX = @"xmlns:a=\"\""; 

Tags: ,

Comments (14) -

personal injury lawyers austin
personal injury lawyers austin United States
1/4/2014 7:28:18 AM #

My web content ... propecia - I have learn a handful of fantastic things right here. Definitely value bookmarking for revisiting. I wonder how so much effort and hard work you set to produce this kind of fantastic informative website.

car accident attorney Austin
car accident attorney Austin United States
1/23/2014 6:53:13 PM #

Also pay a visit to my weblog; viagra - I definitely adore your site.. Pleasant colors & topic. Did you make this incredible internet site oneself? Make sure you reply back as I am setting up to make my really possess site and want to discover where by you obtained this from or just what the topic is called. Respect it!

Austin personal injury lawyers
Austin personal injury lawyers United States
1/26/2014 1:30:49 PM #

in fact a great site. I swriously loove your site.. Really nice colors & concept.

accident attorney Austin
accident attorney Austin United States
2/24/2014 10:39:22 PM #

my web site - viagra on the internet - Excellent tips for new bloggers. Countless men and women focus on Web site rank. Web page rank is useless if the web site does not have very good articles. Ideal now it looks like Wordpress is the ideal running a blog platform available correct now. (from what I have study) Is that what you're utilizing on your own weblog? I almost acquired an heart attac, due in your set of volume. Excellent things even so! Superior tips for new bloggers. So many men and women focus on Website page rank. Page rank is useless if the web site doesn't have excellent information. Fantastic ideas for new bloggers. A lot of people today focus on Web site rank. Web page rank is useless if the web-site doesn't have superior content. I'm unsure exactly where you are getting your info, but fantastic subject matter. I needs to spend a while understanding a great deal more or knowledge far more. Many thanks for wonderful information and facts I used to be seeking for this data for my mission.

million hits secret
million hits secret United States
8/9/2014 1:00:03 PM #

Thanks a lot for your time and effort to have decided to put these things together on this web site. Robin and I very much liked your ideas through the articles with certain things. I understand that you have a number of demands with your program and so the fact that you actually took all the time as you did to help people really like us by way of this article is even highly appreciated.

5 best wordpress security plugins
5 best wordpress security plugins United States
8/16/2014 12:48:21 AM #

Hi there,  You've done an incredible job. I will definitely digg it and personally recommend to my friends. I am confident they will be benefited from this web site.

ford tempo 1993 photos
ford tempo 1993 photos United States
9/30/2014 8:15:10 PM #

Can i give you a small donate about 5$. How can i do it?

1993 ford tempo oil pan price
1993 ford tempo oil pan price United States
9/30/2014 8:15:10 PM #

You late a little with this.

93 ford tempo gl
93 ford tempo gl United States
9/30/2014 8:15:11 PM #

I can`t see any text on the page, except comments

ford tempo body kits
ford tempo body kits United States
9/30/2014 8:15:12 PM #

I have one  good idea for this site. I`ll write it tomorrow)

1991 ford tempo review
1991 ford tempo review United States
9/30/2014 8:15:13 PM #

Lets talk about this, it's an intresting theme

1993 ford tempo reviews
1993 ford tempo reviews United States
9/30/2014 8:15:13 PM #

I wish you to write something else. I think it will be intresting too

1988 ford tempo automatic transmission
1988 ford tempo automatic transmission United States
9/30/2014 8:15:13 PM #

I like this site. It`s very fast and easy reading

Matt P. Kriner
Matt P. Kriner United States
10/3/2014 6:27:13 PM #

I'll gear this review to 2 types of people: current Zune owners who are considering an upgrade, and people trying to decide between a Zune and an iPod. (There are other players worth considering out there, like the Sony Walkman X, but I hope this gives you enough info to make an informed decision of the Zune vs players other than the iPod line as well.)

Pingbacks and trackbacks (1)+

About the author

I started as a VB6 developer, programming all kinds of applications. I also got involved in the development of a e-market in ASP.

When .Net was introduced, I had the privilege to start in a team of professionals and develop a framework. I learned a lot and started to work as a c#.Net consultant from then on.

After 2 years I also got the chance to work for several months with SharePoint. SharePoint kept chasing me all the years after and when the product got more and more mature I started to love it. Then SharePoint was a daily occupation for me. I implemented a large quality document management system at PMRL being the only developer/technical analyst. Working close together with the QA department we succeeded in making and improving a very good Quality document management system. Its used up until this day.

I worked for 6 years as a .Net consultant for 2 of the largest consultancy companies in Belgium. One of my last projects with the consultancy was creating a custom LIMS system in c#.Net. This was a success and the customer asked me to stay and help to expand and maintain this LIMS. I had great years in this company. There was a focus on innovation and a lot of opportunities for improving and developing new IS systems. Apart from several small projects I further more improved the custom LIMS system, created a SOP library based on SharePoint and a web based Skill matrix system to handle the skills of the employees in the company. 

Then I was involved in transferring the LIMS to a new lab in Singapore. This was done in a short time frame. The deployment was again a success and it passed the GLP inspection tests. I learned a lot from the Quality engineers about validation of computerized systems.

At my current job I have a wide range of challenges. Mainly I'm still working with .Net ( and C#.Net). But outside of the Microsoft world I also do some ABAB programming in our SAP system. Like developing Adobe Forms and the program behind it. Or making small changes to customized code.

I'm working for 2 years with objective C now. Creating apps for factories across Europe. People in the factory are working with IPad to take pictures and upload them to orders and more. Already more and more projects are coming my way. The iOS apps are supported by a home made .Net architecture that exposes WCF services. Its working great. My second app is almost ready for deployment in factories. Now I started an App for the management team so they can manage projects on their IPAD and IPHONE. Next generation apps are build with a .Net Web API background combined with EF 6.0.

Soon I will start a new challenge at BDO. In preparation, I started to look into AngularJS. And I'm liking it. It's very fast to use, lots of documentation and works like a charm. Let's see if I'll still be as enthusiastic in a few months. I almost finished my first AngularJS web site. 

My linkedIn!

Month List

Tag cloud

Locations of visitors to this page