J'ai fait un service WCF (service1.svc) ont 2 méthodes.comment appeler la méthode de service WCF dans Iphone
1.GetData()
2.ProductDetails (chaîne PRODID)
deux retourne un fichier au format JSON quand je le fais.
http://192.x.x.x/Demo/Service1.svc/GetData
http://192.x.x.x/Demo/Service1.svc/ProductDetails?prodId=P2
maintenant je veux utiliser ces méthodes dans l'iPhone.
& je les appelle AS-
NSDictionary * arrayDict = [[NSDictionary alloc] init];
NSString *requestString = [NSString stringWithFormat:@"%@", [arrayDict JSONFragment], nil];
NSData *requestData = [NSData dataWithBytes: [requestString UTF8String] length: [requestString length]];
NSString *url = [NSString stringWithFormat:@"http://192.x.x.x/Demo/Service1.svc/ProductDetails/prodId=%@",@"P2"];
NSLog(@"URL %@",url);
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:url]];
NSString *postLength = [NSString stringWithFormat:@"%d", [requestData length]];
[request setHTTPMethod: @"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody: requestData];
theConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
SO s'il vous plaît me dire comment appeler cette méthode [Productdetails (string PRODID)] dans Iphone
Excellent exemple de code - merci! –
Mais je veux appeler une méthode qui a un argument , c'est-à-dire ProductDetails (chaîne ProdId) la méthode sans argument fonctionne aussi pour moi. Quoi qu'il en soit Merci .... mais j'espère que vous allez répondre à cette question. – user372079
Vous pouvez ajouter cela dans votre en-tête de savon, votre en-tête va changer. dans mon exemple, s'il y a besoin de passer un nom de paramètre startsWith qui est string alors l'enveloppe devrait ressembler à ceci: I GetDictionary> SOAP-ENV: Corps> SOAP-ENV: Enveloppe> –
IBhadelia