青蛙爱大莹宝 2015-04-02 12:06 采纳率: 100%
浏览 3281
已采纳

IOS 调用C#写的Webservice ,传递的参数到Webservice取出的值为NULL

问题描述:IOS 调用C#写的Webservice ,传递的参数到Webservice取出的值为NULL,传递前在IOS里测试能取到值,麻烦用过这块的帮我看一下,已困扰我两天 啦~~哈哈

代码:

NSMutableString *tps=[NSMutableString stringWithString:@""]; //存储参数名称
NSMutableString *vps=[NSMutableString stringWithFormat:@""];//存储参数值
NSMutableString *ts=[NSMutableString stringWithFormat:@""];//组合字符串变量
NSMutableString *mreakString=[NSMutableString stringWithFormat:@""];//组合字符串变量
[mreakString appendString:@"<"];
[mreakString appendString:MethodName]; //方法名
[mreakString appendString:@" xmlns=\"http://tempuri.org/\">"];
//[ParametersKey count]

for (int i = 0; i <[ParametersKey count]; i++)
{
    tps = [ParametersKey objectAtIndex:i];
    vps = [ParametersValue objectAtIndex:i];
    [ts appendString:@"<"];
    [ts appendString:@"cnono"];//参数名
    [ts appendString:@">"];
    [ts appendString:@"17"]; //参数值  (--- 17 传递到webservice为NULL值 ----)
    [ts appendString:@"</"];
    [ts appendString:@"cnono"];
    [ts appendString:@">"];
    [mreakString appendString:ts];
}
[mreakString appendString:@"</"];
[mreakString appendString:MethodName];
[mreakString appendString:@">"];
NSMutableString *soapMessage2=[NSMutableString stringWithFormat:@""];;
[soapMessage2 appendString:@"</soap:Envelope>"];

生成的协议字符串为:

requestData-----><?xml version="1.0" encoding="utf-8"?>



/soap:Body
/soap:Envelope

<cnono>17</cnono>

/soap:Envelope

服务器返回的串为:

<?xml version="1.0" encoding="utf-8"?>soap:Body1:webservicer return:Sql=delete from C where Cno=,param=/soap:Body/soap:Envelope

  • 写回答

3条回答 默认 最新

  • 青蛙爱大莹宝 2015-04-04 11:55
    关注

    问题解决了是拼接的SOAP串的事,按照标准的串拼接后,问题解决。

    标准串:
    SOAP 1.1

    以下是 SOAP 1.2 请求和响应示例。所显示的占位符需替换为实际值。
    POST /StockTest/Service1.asmx HTTP/1.1
    Host: localhost
    Content-Type: text/xml; charset=utf-8
    Content-Length: length
    SOAPAction: "http://tempuri.org/deleteCargoInfo"

    <?xml version="1.0" encoding="utf-8"?>

    soap:Body

    string

    /soap:Body
    /soap:Envelope

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元