简体   繁体   English

网络服务iPhone

[英]Web service iPhone

I'm trying to connect to a web service, with the next code: 我正在尝试使用以下代码连接到Web服务:

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);

But I obtain the same reply, than if I don't send parameters. 但是,与不发送参数相比,我得到的答复是相同的。


I got this: 我懂了:

[Session started at 2009-07-07 22:01:53 +0200.]
2009-07-07 22:01:57.669 Hello_SOAP[6058:20b] Result:{
}

Exactly, seems like this but I will show you also the parameters that the method needs: 确实如此,但是我还将向您展示该方法所需的参数:

SOAP Request 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> 

As you can see, the name of the parameters that I need are arg0 and arg1 , for this I can't understand what is going wrong :) 如您所见,我需要的参数名称为arg0arg1 ,为此,我无法理解出了什么问题:)

Try posting the reply you get. 尝试发布您收到的回复。 It seems like you're parameters are incorrect, given that you get the same response as if you sent no parameters. 似乎您输入的参数不正确,因为您收到的响应与未发送任何参数一样。

Danger. 危险。 Are you are aware that WSMethodInvocationRef (or any of the SOAP helper classes) do not exist on the iPhone? 您是否知道iPhone上不存在WSMethodInvocationRef(或任何SOAP帮助器类)? (your question is tagged as iPhone). (您的问题被标记为iPhone)。

It will compile for the simulator but not for the phone. 它将针对模拟器而不是针对手机进行编译。 I'd hate to see you waste much time getting this working if your real target is the device and not the Mac. 如果您的真正目标是设备而不是Mac,我不希望看到您浪费大量时间来使此工作正常进行。

Instead use wsdl2objc . 而是使用wsdl2objc

Who knows, that may well solve your problem - since it's a stub generation approach it probably will work fine. 谁知道,那很可能会解决您的问题-因为这是一种存根生成方法,所以可能会很好用。

If possible though, I'd recommend using REST for server communication instead of SOAP. 如果可能的话,我建议使用REST代替SOAP进行服务器通信。 Depends on what control you have over the server. 取决于对服务器的控制权。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM