[英]Web service don't call from objective c, soap request
从我的 iphone 应用程序调用的服务目标不是我的代码如下:
Web 服务位于http://tuturno.knowit.cl/soap/colas.php上的 php 中,功能如下:
function registrocola ($param1){
$obj = json_decode($param1);
$hoy = date("Y-m-d H:i:s");
include_once 'RegistroCola.php';
include_once 'ControlSOAP.php';
$registro = new RegistroCola();
$registro->cliente = $obj->{'cliente'};
$registro->cola = $obj->{'cola'};
$registro->fecha = $hoy;
$registro->iddispositivo = $obj->{'idDispositivo'};
$registro->numero = $obj->{'numero'};
$registro->sucursal = $obj->{'sucursal'};
$out = ControlSOAP::registrar($registro);
return $out;}
来自我的 iphone 应用程序的电话如下:
// Build dictionnary with parameters
NSMutableDictionary *dictionnary = [NSMutableDictionary dictionary];
[dictionnary setObject:[tiket codigoSucursal] forKey:@"sucursal"];
[dictionnary setObject:[tiket cliente] forKey:@"cliente"];
[dictionnary setObject:[tiket letraCola] forKey:@"cola"];
[dictionnary setObject:[tiket nroTicket] forKey:@"numero"];
[dictionnary setObject:[tiket idDispositivo] forKey:@"idDispositivo"];
[dictionnary setObject:@"2014-11-02" forKey:@"fecha"];
NSError *error = nil;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dictionnary
options:kNilOptions
error:&error];
NSURL *url = [NSURL URLWithString: URL];
NSString *soapAction=[NSString stringWithFormat:@"%@%@",SOAP_ACTION,METHOD_REGISTER];
NSDictionary *headField=[NSDictionary dictionaryWithObjectsAndKeys:[url host],@"Host",
@"text/xml; charset=utf-8",@"Content-Type",
soapAction,@"SOAPAction",nil];
// Prepare the request
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setAllHTTPHeaderFields:headField];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setValue:@"json" forHTTPHeaderField:@"Data-Type"];
[request setHTTPBody:jsonData];
NSError *errorReturned = nil;
NSURLResponse *theResponse =[[NSURLResponse alloc]init];
NSData *data = [NSURLConnection sendSynchronousRequest:request
returningResponse:&theResponse
error:&errorReturned];
打电话给服务说肥皂请求不好
这是来自 php 的测试调用 webservice
$client = new SoapClient(null, array(
'location' => DatosSOAP::$LOCATION."/colas.php",
'uri' => DatosSOAP::$URI,
'trace' => 1 ));
$hoy = date("Y-m-d H:i:s");
$params = array('cliente'=>'99', 'sucursal'=>'99', 'cola'=>'A', 'iddispositivo'=>'Galaxy', 'numero'=>'33', 'fecha'=>$hoy);
$return = $client->__soapCall("registrocola",array($params));
echo("\nReturning value of __soapCall() call: ".$return);
echo("<br><br><br>\nDumping request headers:\n"
.$client->__getLastRequestHeaders());
echo("\nDumping request:\n".$client->__getLastRequest());
echo("\nDumping response headers:\n"
.$client->__getLastResponseHeaders());
echo("\nDumping response:\n".$client->__getLastResponse());
肥皂服务是否返回 XML 或 JSON?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.