我需要以XML格式創建一個NSString
,所以我需要將它發送的Web服務請求。以XML格式創建的NSString作爲請求iPhone的SDK,以web服務器?
我已經創建的XML使用此代碼
NSMutableString *res = [NSMutableString string];
[res appendString:@"<question>"];
[res appendFormat:@"<productid>%@</productid>", [array objectAtIndex:0]];
[res appendFormat:@"<questionid>%@</questionid>", [array objectAtIndex:1]];
[res appendFormat:@"<valueid>%@</valueid>", [array objectAtIndex:2]];
[res appendFormat:@"<answerText>%@</answerText>", [array objectAtIndex:3]];
[res appendFormat:@"</question>"];
但是,結構NSString
當我送這是一個請求(Web服務代碼中使用sudzc創建的),我得到了一些錯誤
Entity: line 1: parser error : Start tag expected, '<' not found
Bad Request
Error: The operation couldn’t be completed. (CXMLErrorDomain error 1.)
這是我發送的字符串
NSString *send=[NSString stringWithString:@"<request><ProductName>ppr</ProductName><questionid>fff</questionid><answerText>%@</answerText></request>"];
什麼是所有的標籤我應該在創建字符串xml的地方?
這裏是我的要求,,
[service CreateRequest:self action:@selector(CreateRequestHandler:) Email:@"xxxx" Password:@"anoopgopalan" Token:@"xxx" Request:send];
- (void) CreateRequestHandler: (id) value {
// Handle errors
if([value isKindOfClass:[NSError class]]) {
NSLog(@"%@", value);
return;
}
// Handle faults
if([value isKindOfClass:[SoapFault class]]) {
NSLog(@"%@", value);
return;
}
// Do something with the MFLAPIError* result
MFLAPIError* result = (MFLAPIError*)value;
NSLog(@"CreateRequest returned the value: %@", result);
}
你缺少一些標籤.. – vishy
@vishy我不知道到底是什麼我缺少 –
看到我的回答如下..這一個嘗試.. – vishy