我有一個數組,其中包含一些內部的索引。當我登錄它時它看起來是這樣的:IOS如何向SOAP消息中插入數組
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");
}
你想插入3個號碼1塊肥皂嗎?或每個請求的每個號碼?你的代碼有什麼問題? – anhtu
我想插入3個數字給1個肥皂。代碼插入一個數字沒有問題。但我想傳入3個數字到這個肥皂,但它失敗,因爲我不知道如何。 – zac
我看到'soapMessage'只有一個放置數字的地方?你想要什麼格式? – anhtu