我正在肥皂网络服务和 iOS 应用程序之间建立连接并完成连接,但我收到错误 HTTP 200。
我该如何解决这个错误?
代码
-(IBAction)buttonClick:(id)sender
{
dig = @"م ط ر" ;
cha =@"0158";
NSString *soapMessage = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
"<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">"
"<s:Body>"
"<GetCarDataByPlate xmlns=\"http://tempuri.org/\">"
"<params>"
"<PlateDigits>%@</PlateDigits>"
"<PlateStr>%@</PlateStr>"
"<Pass>Mob.2013</Pass>"
"</params>"
"</GetCarDataByPlate>"
"</s:Body>"
"</s:Envelope>",dig,cha];
NSLog(@"%@", soapMessage);
NSURL *url = [NSURL URLWithString:@"http://www.uis.com.sa/Wcf_MobileS/MobileService.svc?wsdl"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];
[theRequest addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue:@"http://tempuri.org/IMobileService/GetCarDataByPlate" forHTTPHeaderField:@"SOAPAction"];
[theRequest addValue:msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody:[soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
NSLog(@"theConnection = %@",theConnection);
if(theConnection)
{
webData = [NSMutableData data];
NSLog(@"WebData = %@",webData);
}
else
{
NSLog(@"theConnection is null");
}
}
-(void)connection:(NSURLConnection*)connection didReceiveResponse:(NSURLResponse*)response
{
[webData setLength:0];
NSHTTPURLResponse * httpResponse;
httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"HTTP error %zd", (ssize_t) httpResponse.statusCode);
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData*)data
{
[webData appendData:data];
// NSLog(@"webdata: %@", data);
}
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError*)error
{
NSLog(@"error with the connection");
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSLog(@"DONE. Received bytes %d", [webData length]);
NSString *theXML = [[NSString alloc] initWithBytes:[webData mutableBytes] length:[webData length] encoding:NSUTF8StringEncoding];
NSLog(@"xml %@",theXML);
}