<iOS>网络编程SOAP, WSDL, Web Service(3)
来源:未知 责任编辑:责任编辑 发表时间:2013-12-01 14:19 点击:次
[xmlParsersetDelegate: self];
[xmlParsersetShouldResolveExternalEntities:YES];
[xmlParser parse];
[connection release];
}
// 上面完成了数据的接收, 下面进行NSXMLParser 的解析。
-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *) namespaceURI qualifiedName:(NSString *)qName
attributes: (NSDictionary *)attributeDict
{
NSLog(@"4 parser didStarElemen: namespaceURI: attributes:%@", elementName);
if( [elementNameisEqualToString:@"LocalTimeByZipCodeResult"]) {
if(!soapResults) {
soapResults = [[NSMutableString alloc] init];
}
recordResults =YES;
}
}
-(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
NSLog(@"5 parser: foundCharacters:");
if(recordResults) {
[soapResultsappendString: string];
}
}
-(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
NSLog(@"6 parser: didEndElement:");
if( [elementNameisEqualToString:@"LocalTimeByZipCodeResult"]) {
recordResults =FALSE;
NSLog(@"receivedResult timezone=%@",soapResults);
[soapResultsrelease];
soapResults = nil;
NSLog(@"hoursOffset result");
}
}
- (void)parserDidStartDocument:(NSXMLParser *)parser{
NSLog(@"-------------------start--------------");
}
- (void)parserDidEndDocument:(NSXMLParser *)parser{
NSLog(@"-------------------end--------------");
}
我们再查一下,这个web service返回的数据是怎么样的?如下:
HTTP/1.0 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: string
<?xml version="1.0" encoding="utf-16"?>
<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>
相关新闻>>
- 发表评论
-
- 最新评论 更多>>