网络服务iPhone
我正在尝试连接到web服务,代码如下:网络服务iPhone,iphone,web-services,soap,Iphone,Web Services,Soap,我正在尝试连接到web服务,代码如下: NSURL *soapURL; WSMethodInvocationRef soapCall; NSString *methodName; NSMutableDictionary *params; NSDictionary *result; soapURL = [NSURL URLWithString:@"http://wicaweb2.intec.ugent.be:80/FaceTubeWebServiceService/FaceTubeWebServ
NSURL *soapURL;
WSMethodInvocationRef soapCall;
NSString *methodName;
NSMutableDictionary *params;
NSDictionary *result;
soapURL = [NSURL URLWithString:@"http://wicaweb2.intec.ugent.be:80/FaceTubeWebServiceService/FaceTubeWebService?WSDL"];
methodName = @"getMostViewed";
soapCall = WSMethodInvocationCreate((CFURLRef)soapURL,
(CFStri ngRef)methodName, kWSSOAP2001Protocol);
params = [NSMutableDictionary dictionaryWithCapacity:2];
[params setObject:@"1" forKey:@"arg0"];
[params setObject:@"all_time" forKey:@"arg1"];
NSArray *paramsOrder = [NSArray arrayWithObjects:@"arg0",@"arg1", nil];
WSMethodInvocationSetParameters(soapCall,
(CFDictionaryRef)params,(CFArrayRef)paramsOrder);
WSMethodInvocationSetProperty(soapCall,
kWSSOAPMethodNamespaceURI,
(CFTypeRef)@"http://webservice.facetube.wica.intec.ugent.be/");
result = (NSDictionary*)WSMethodInvocationInvoke(soapCall);
NSString *resultado = [result objectForKey: (NSString*)kWSMethodInvocationResult];
NSLog(@"Result:%@",resultado);
但是如果我不发送参数,我会得到相同的答复
我明白了:
[Session started at 2009-07-07 22:01:53 +0200.]
2009-07-07 22:01:57.669 Hello_SOAP[6058:20b] Result:{
}
没错,看起来是这样的,但我将向您展示该方法所需的参数:
SOAP请求
>
>xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/"
>xmlns:xsd=”http://www.w3.org/2001/XMLSchema"
>xmlns:ns1=”http://webservice.facetube.wica.intec.ugent.be/">
>
>
> 1
>一直
>
>
正如您所看到的,我需要的参数名称是
arg0
和arg1
,因此我无法理解出现了什么问题:)尝试发布您收到的回复。您的参数似乎不正确,因为您得到的响应与未发送参数的响应相同。危险。您知道iPhone上不存在WSMethodInvocationRef(或任何SOAP助手类)吗?(你的问题被标记为iPhone)
它将为模拟器而不是手机编译。如果你真正的目标是设备而不是Mac电脑,我不希望看到你浪费太多时间让它工作
而是使用
谁知道呢,这可能会很好地解决您的问题——因为这是一种存根生成方法,它可能会很好地工作
不过,如果可能的话,我建议使用REST进行服务器通信,而不是使用SOAP。取决于您对服务器的控制
> <?xml version="1.0" encoding="UTF-8"?>
> <soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:ns1="http://webservice.facetube.wica.intec.ugent.be/">
> <soapenv:Body>
> <ns1:getMostViewed>
> <arg0>1</arg0>
> <arg1>all_time</arg1>
> </ns1:getMostViewed>
> </soapenv:Body> </soapenv:Envelope>