OData Client for Obj-C and Parsing Out Scalar Return Values

185 views Asked by At

I can't seem to find a way for the Objective-C OData client to return the value of a web service function that just returns something simple, like an integer.

For example,

[WebInvoke]
public Int32 xyx()
{
return ( 3 );
}

The proxy-generated client code generates a function that when called, returns an XML formatted NSString with the value 3 in it. Am I going to have to parse out this value and then map it to an int? I thought it would be easier. Even harder for bools. Net bools are true/false, when Obj-C are YES/NO. You would have to write code that parses the XML, finds the true/false, ifs it to YES/NO, arrgggg.

I thought the OData client would map these, am I wrong?

1

There are 1 answers

1
BrainMan On

Just wondering if anyone has an answer on this on yet. I'm in the same boat. In my situation, I'm using the .Net client side proxy (Add Service Reference), it's very similar in this situation. I end up having to call my service method using:

context.Execute<int32>(new Uri(MyUri, UriKind.Relative)).ToList();

This gives me back an ICollection with 1 item. It works, but it's certainly not very clean! Hoping someone has a better solution.

I'm also interested in the correct way to access the "post data" from inside the service method. I haven't tried it yet, but based on other things I've done, I'm thinking something like this:

HttpRequest ThisRequest = (HttpRequest)System.Web.HttpContext.Current.Request;
string PostData = ThisRequest.Form["PostData"];

OData documentation not very clear about this stuff. Thanks!!