NSString *soapMsg=[NSStringstringWithFormat:@"<?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>"
"<getWeatherbyCityName xmlns=\"http://WebXml.com.cn/\">"
"<theCityName>%@</theCityName>"
"</getWeatherbyCityName>"
"</soap:Body>"
"</soap:Envelope>",@"青岛"
];
NSURL *url=[NSURLURLWithString:@"http://www.webxml.com.cn/WebServices/WeatherWebService.asmx"];
NSString *msgLength=[NSString stringWithFormat:@"%d",[soapMsg length]];
NSMutableURLRequest *request=[NSMutableURLRequestrequestWithURL:url];
[requestaddValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[request addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[request setHTTPMethod:@"POST"];
[requestsetHTTPBody:[soapMsgdataUsingEncoding:NSUTF8StringEncoding]];
NSData *data=[NSURLConnectionsendSynchronousRequest:requestreturningResponse:nilerror:nil];
NSMutableString *result=[[NSMutableStringalloc]initWithData:dataencoding:NSUTF8StringEncoding];
NSLog(@"获得结果是%@",result);