0
我想從目標C做一個WCF服務調用。我在下面生成一個代碼,我再次從Web上的某個地方執行代碼。我無法弄清楚我會在哪裏提到要調用的特定方法。如何指定在來自Objective C的服務調用中調用WCF服務中的哪個方法?
-(void)viewDidLoad {
[super viewDidLoad];
//Web Service Call
NSString *soapMessage = [NSString stringWithFormat:
@\"<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?>\n\"
\"<SOAP-ENV:Envelope \n\"
\"xmlns:xsd=\\"http://www.w3.org/2001/XMLSchema\\" \n\"
\"xmlns:xsi=\\"http://www.w3.org/2001/XMLSchema-instance\\" \n\"
\"xmlns:SOAP-ENC=\\"http://schemas.xmlsoap.org/soap/encoding/\\" \n\"
\"SOAP-ENV:encodingStyle=\\"http://schemas.xmlsoap.org/soap/encoding/\\" \n\"
\"xmlns:SOAP-ENV=\\"http://schemas.xmlsoap.org/soap/envelope/\\"> \n\"
\"<SOAP-ENV:Body> \n\"
\"<GetMembers mlns=\\"http://tempuri.org/\\">\"
\"</GetMembers> \n\" \"</SOAP-ENV:Body> \n\"
\"</SOAP-ENV:Envelope>\"];
//[[NSURLCache sharedURLCache] removeAllCachedResponses];
NSURL *url = [NSURL URLWithString:@\"http://[IP_ADDRESS_OF_WCF_SERVER]/IphoneService/Service1.svc\"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@\"%d\", [soapMessage length]];
[theRequest addValue: @\"text/xml; charset=utf-8\" forHTTPHeaderField:@\"Content-Type\"];
[theRequest addValue: @\"http://tempuri.org/IService1/GetMembers\" forHTTPHeaderField:@\"Soapaction\"];
[theRequest addValue: msgLength forHTTPHeaderField:@\"Content-Length\"];
[theRequest setHTTPMethod:@\"POST\"];
[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if(theConnection) {
webData = [[NSMutableData data] retain];
}
else {
NSLog(@\"theConnection is NULL\");
}
}
可以說我有一個方法iPhoneMethod()在服務服務1,我提這個呼叫哪裏?或者可能有一些其他的方式。是這樣在ajax調用中,「http:// [IP]/[服務路徑] /Service1.svc/iPhoneMethod」