Mam pewną książkę jest w niej opisany dostęp do serwisu Łebowego Amazon.W książce jest między innymi taki tekst:
Cytat
Web services are getting a lot of hype. In the end, however, they are simply an HTTP request and response whereby each may be carrying XML data. So using a Web service from Cocoa is simply a matter of being able to send HTTP requests and receive responses. It also may require generating and parsing XML.
i jest kawałek programu:
Kod
// Get the string and percent-escape for insertion into URL NSString *input = [searchField stringValue]; NSString *searchString =
[input stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
NSLog(@"searchString = %@", searchString);
// Create the URL (Long string broken into several lines is OK) NSString *urlString = [NSString stringWithFormat:
@"http://ecs.amazonaws.com/onca/xml?"
@"Service=AWSECommerceService&"
@"AWSAccessKeyID=%@&"
@"Operation=ItemSearch&"
@"SearchIndex=Books&"
@"Keywords=%@&"
@"Version=2007-07-16", AWS_ID, searchString];
NSURL *url = [NSURL URLWithString:urlString]; NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url
cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:30];
[input stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
NSLog(@"searchString = %@", searchString);
// Create the URL (Long string broken into several lines is OK) NSString *urlString = [NSString stringWithFormat:
@"http://ecs.amazonaws.com/onca/xml?"
@"Service=AWSECommerceService&"
@"AWSAccessKeyID=%@&"
@"Operation=ItemSearch&"
@"SearchIndex=Books&"
@"Keywords=%@&"
@"Version=2007-07-16", AWS_ID, searchString];
NSURL *url = [NSURL URLWithString:urlString]; NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url
cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:30];
Teraz moje pytanie: Czy w ten sposób można wywołać odpowiedź kaźdego serwisu, przy pomocy tego przydługiego adresu URL wpisanego np. w przeglądarce?