【发布时间】:2015-11-20 07:06:13
【问题描述】:
我有一个数组,其中包含一些索引。当我注销它时,它看起来像这样:
item pass: (
80340025,
80319340,
80251277
)
我的数组被声明为 NSAAray
然后我需要进行一次soap调用,将这个数组的每个索引插入到soap消息中。问题是如何?
这是我的肥皂信息。
NSString *soapMessage = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
"<soap:Body>"
" <IncidentQuery xmlns=\"https://www.monitoredsecurity.com/\">"
"<IncidentNumber>%d</IncidentNumber>"
"<MaxSignatures></MaxSignatures>"
"</IncidentQuery>"
"</soap:Body>"
"</soap:Envelope>", item_pass];
NSURL *url = [NSURL URLWithString:@"https://api.monitoredsecurity.com/SWS/incidents.asmx"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%lu", (unsigned long)[soapMessage length]];
[theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue: @"https://www.monitoredsecurity.com/IncidentQuery" forHTTPHeaderField:@"SOAPAction"];
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
[connection start];
if(connection)
{
_webResponseData = [NSMutableData data] ;
}
else
{
NSLog(@"Connection is NULL");
}
【问题讨论】:
-
您想在 1 个肥皂中插入 3 个数字吗?还是每个请求的每个数字?你的代码有什么问题?
-
我想在 1 个肥皂中插入 3 个数字。代码插入一个数字没有问题。但我想将 3 个数字传递给这个肥皂,但它失败了,因为我不知道怎么做。
-
我看到
soapMessage只有一个地方可以放号码?你想要什么格式? -
%d 是我传入数组数量但我不知道如何的地方
-
你想要“
80340025, 80319340, 80251277 ”?
标签: ios objective-c arrays web-services soap