我使用textfield输入我的web服务的字段。例如我输入了StationID textfield = 35016。
我有770个StationID,每个站都有一个名字。 stationId 35016名称是新伊斯坦布尔有限公司STI。我想当我进入新搜索栏时,它必须向我列出新伊斯坦布尔有限公司.STI。我将选择发送网络服务电话。
如何进行搜索和选择搜索字段。这个代码用于Textfield。如何更改搜索栏?谢谢。
<。>文件中的
#import <UIKit/UIKit.h>
@interface AMDViewController : UIViewController<UITextFieldDelegate,NSXMLParserDelegate>
@property (unsafe_unretained, nonatomic) IBOutlet UITextField *StationID;
@end
<。>文件中的
enter code here
#import "AMDViewController.h"
@interface AMDViewController ()
{
NSMutableData *webData;
NSXMLParser *xmlParser;
NSMutableString *retornoSOAP;
BOOL teveRetorno;
@end
@implementation AMDViewController
@synthesize StationID;
}
-(IBAction)calcularTemperatura:(UIButton *)sender{
NSString *mensagemSOAP= [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
"<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/\">\n"
"<soap:Body>\n"
"<Details xmlns=\"http://tempuri.org/\">\n"
"<StationID>%@</StationID>\n"
"<StationName>%@</StationName>\n" //StationName is here in web sevrice
"</Details>\n"
"</soap:Body>\n"
"</soap:Envelope>\n",StaionID.text];
NSLog(@"SOAP msg = \n%@\n\n", mensagemSOAP);
NSURL *url = [NSURL URLWithString:@"http://webservice/sample.asmx"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url]; NSString *tamanhoMensagem = [NSString stringWithFormat:@"%d", [mensagemSOAP length]];
[theRequest addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue: @"http://tempuri.org/Details" forHTTPHeaderField:@"SOAPAction"];
[theRequest addValue:tamanhoMensagem forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody:[mensagemSOAP dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection *conexao = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if(conexao){
webData = [NSMutableData data];
}else{
NSLog(@"Connection Error.");
}
}
-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{
if ( [elementName isEqualToString:@"StationID"] ) {
if (!retornoSOAP) {
retornoSOAP = [[NSMutableString alloc] init];
}
teveRetorno = YES;
}
}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI: (NSString *)namespaceURI qualifiedName:(NSString *)qName{
if ( [elementName isEqualToString:@"StationID"] ) {
StaionTotalSalesTodayLabel.text = retornoSOAP;
retornoSOAP = nil;
teveRetorno = NO;
}