我正在从 objective-c 调用 .Net WCF 服务。我必须将“类别”类型的对象传递给函数。在传递对象之前,我必须初始化它的“id”。这是代码:
SDZiPadDocSyncService *service = [[SDZiPadDocSyncService alloc]init];
service.logging = YES;
SDZCategory *cat = [[SDZCategory alloc]init];
cat.categoryId = [catId intValue];
[service getDocsByCatId:self action:@selector(getDocsByCatIdHandler:) category:cat];
当调用到达 SQL Server 时,categoryId 为 0。由于没有任何 Id=0 的类别,服务返回 0 条记录。有人可以帮我吗?
最佳答案
WCF 服务可能没有正确反序列化请求。要验证 sudzc 正在生成 WCF 服务所期望的 soap XML,请使用 the WcfTestClient.exe app that comes with Visual Studio调用 getDocsByCatId
方法。在请求/响应面板中,您会看到一个 XML 选项卡。将 sudzc XML 与该选项卡中的 XML 进行比较。
有时 WCF 期望 XML 命名空间在肥皂正文中显式使用。例如,您的肥皂显示 categoryId
元素位于 xmlns="http://tempuri.org/"
XML 命名空间,因为这是默认命名空间。确保来自 WcfTestClient 的 soap XML 也放置 categoryId
在 http://tempuri.org/
XML 命名空间。如果不这样做,不知道如何配置 sudzc。
关于objective-c - 将属性分配给 sudzc 中的对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11965267/