对于iPhone App,下面的输入是否足以请求SOAP web方法?在Android中,method_name,soap_action,namespace,url和输入参数就足够了。 iOS应用程序怎么样?
我看了一下iPhone代码示例 -
-(IBAction)btnFindCountry:(id)sender {
NSString *soapMsg =
[NSString stringWithFormat:
@"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
"<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>"
"<GetGeoIP xmlns=\"http://www.webservicex.net/\">"
"<IPAddress>3.4.5.6</IPAddress>"
"</GetGeoIP>"
"</soap:Body>"
"</soap:Envelope>"];
//---print it to the Debugger Console for verification---
NSLog(@"%@",soapMsg);
NSURL *url = [NSURL URLWithString:
@"http://www.webservicex.net/geoipservice.asmx"];
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
//---set the various headers---
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMsg length]];
[req addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[req addValue:@"http://www.webservicex.net/GetGeoIP" forHTTPHeaderField:@"SOAPAction"];
[req addValue:msgLength forHTTPHeaderField:@"Content-Length"];
//---set the HTTP method and body---
[req setHTTPMethod:@"POST"];
[req setHTTPBody:[soapMsg dataUsingEncoding:NSUTF8StringEncoding]];
//---start animating--
[activityIndicator startAnimating];
conn = [[NSURLConnection alloc] initWithRequest:req delegate:self];
if (conn) {
webData = [[NSMutableData data] retain];
}
}
我提供以下网络服务...如何将其转换为我的iPhone应用程序代码,如上所述?
Name: xxyy
Binding: Book247XMLWebServiceForMobileBinding
Endpoint: yyxx.com/webservice/indexMobile.php
SoapAction: yyxx.com/webservice/Book247XMLWebServiceForMobile.wsdl#tGetSearchDataByCategories
Style: rpc
Input:
use: encoded
namespace: yyxx.com/webservice/Book247XMLWebServiceForMobile.wsdl
encodingStyle: schemas.xmlsoap.org/soap/encoding/
message: tGetSearchDataByCategoriesRequest
parts:
vendor_access_url: xsd:string
category_id: xsd:integer
subcategory_id: xsd:integer
Output:
use: encoded
namespace: yyxx.com/webservice/Book247XMLWebServiceForMobile.wsdl
encodingStyle:schemas.xmlsoap.org/soap/encoding/
message: xxyy
parts:
return: tns:Searches
Namespace: webservice/Book247XMLWebServiceForMobile.wsdl
Transport: schemas.xmlsoap.org/soap/http
感谢您的期待。