Obj-C 的 OData 客户端和解析标量返回值
我似乎找不到一种方法让 Objective-C OData 客户端返回仅返回简单内容(例如整数)的 Web 服务函数的值。
例如,
[WebInvoke]
公共 Int32 xyx()
{
返回(3);
。
代理生成的客户端代码生成一个函数,该函数在调用时返回一个 XML 格式的 NSString,其中包含值 3 我是否必须解析这个值然后将其映射到 int ?我以为这样会更容易。对于布尔值来说更难。当 Obj-C 为 YES/NO 时,Net bools 为 true/false。您必须编写代码来解析 XML,查找真/假,如果是/否,arrgggg。
我以为 OData 客户端会映射这些,我错了吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只是想知道是否有人对此有答案。我在同一条船上。在我的情况下,我使用 .Net 客户端代理(添加服务引用),在这种情况下非常相似。我最终不得不使用以下方法调用我的服务方法:
这给了我一个包含 1 项的 ICollection。它可以工作,但肯定不是很干净!希望有人有更好的解决方案。
我还对从服务方法内部访问“发布数据”的正确方法感兴趣。我还没有尝试过,但根据我所做的其他事情,我在想这样的事情:
OData 文档对此内容不是很清楚。谢谢!!
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:
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:
OData documentation not very clear about this stuff. Thanks!!