程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> webservice-IOS 調用C#寫的Webservice ,傳遞的參數到Webservice取出的值為NULL

webservice-IOS 調用C#寫的Webservice ,傳遞的參數到Webservice取出的值為NULL

編輯:編程綜合問答
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

最佳回答:


問題解決了是拼接的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

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved