我有 WSDL 网址。我在 WSDL 中有两个方法,我需要访问这些方法并使用 REST api 获得响应。
我尝试过的如下?
我使用以下代码片段进行请求和响应。但我没有得到任何回应。
- (void)viewDidLoad
{
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURLNSURL : [URLWithString"https://mywebsite.com/service.svc?wsdl"]];
[request setHTTPMethod"IBillingSubmissionService_RegisterDevice_InputMessage"];
NSURLConnection *myConnection = [NSURLConnection connectionWithRequest:request delegate:self];
[myConnection start];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
[dataWebService setLength:0];
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
NSLog(@"Response: %@",data);
[dataWebService appendData:data];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
NSString *responseString = [[NSString alloc] initWithData:dataWebService encoding:NSUTF8StringEncoding];
NSLog(@"Response: %@",responseString);
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
NSLog(@"Eror during connection: %@", [error description]);
}
我在上面做什么是正确的?有人可以提供一个示例代码片段来使用 REST 调用和获取响应吗?
我想知道以下内容:
1) 如何将值传递给 WSDL 方法?
2)如何通过请求并获得响应?