【发布时间】:2015-04-05 06:09:09
【问题描述】:
我是 SOAP API 的新手。
我正在使用以下代码访问我的 API。
NSString *stringURL=[NSString stringWithFormat:@"http://tennispro.co.in/services.asmx"];
// Allocate and initialize an NSURLConnection with the given request and delegate. The asynchronous URL load process is started as part of this method.
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>"
"<ReturnSyncMasterData xmlns=\"http://tempuri.org/\">"
"<datetime>%@</datetime>"
"</ReturnSyncMasterData>"
"</soap:Body>"
"</soap:Envelope>",@""];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:stringURL]];
[request addValue:@"text/html; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[request addValue:@"2159" forHTTPHeaderField:@"Content-Length"];
[request addValue:@"private, max-age=0" forHTTPHeaderField:@"Cache-Control"];
[request addValue:@"gzip" forHTTPHeaderField:@"Content-Encoding"];
[request addValue:@"http://tempuri.org/services/ReturnSyncMasterData" forHTTPHeaderField:@"SOAPAction"];
[request setHTTPBody:[soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPMethod:@"POST"];
theConnection = [NSURLConnection connectionWithRequest:request delegate:self];
if (theConnection) {
receivedData = [[NSMutableData alloc] init];
}
但作为回应,我得到的是 HTML 而不是 XML。我想访问ReturnSyncMasterData 肥皂动作,但我无法调用它。
【问题讨论】:
标签: ios asp.net iphone web-services soap