4

Thanks for reading.

I'm trying to consume the data from here: Data Link So, I'm trying to implement the new Afnetworking framework on my ios app. I Write this:

   NSURL *baseURL = [NSURL URLWithString:@"http://www.virtualdemos.com.ar/RPSistemas/InformeDiario/WsInformeDiario/Services.asmx?op=GetEmpresasJson"];

NSString *soapBody = [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><GetEmpresasJson xmlns=\"http://tempuri.org/\"><empresaRequestJson>%@</empresaRequestJson></GetEmpresasJson></soap:Body></soap:Envelope>", @"0035" ];



NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:baseURL];

[request setHTTPMethod:@"POST"];
[request setHTTPBody:[soapBody dataUsingEncoding:NSUTF8StringEncoding]];

[request addValue:@"http://tempuri.org/GetEmpresasJson" forHTTPHeaderField:@"SOAPAction"];

[request addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];

AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];

[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
    // do whatever you'd like here; for example, if you want to convert
    // it to a string and log it, you might do something like:

    NSString *string = [[NSString alloc] initWithData:responseObject encoding:NSUTF8StringEncoding];
    NSLog(@"%@", string);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    NSLog(@"%s: AFHTTPRequestOperation error: %@", __FUNCTION__, error);
}];


[operation start];

The call appears work, but, the server return me:

2014-02-05 12:29:28.842 InformeDiario[1675:70b] <?xml version="1.0" encoding="utf-8"?>    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"     xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><GetEmpresasJsonResponse     xmlns="http://tempuri.org/"><GetEmpresasJsonResult>{
  "Empresas": [],
  "Error": {
    "Code": 2,
    "Description": "Error converting value 29 to type 'InformeDiario.Entity.EmpresaRequest'. Path '', line 1, position 4.",
    "FaultCode": 0
  },
  "MobileFechaSync": null,
  "ServerReceivedFechaSync": null,
  "ServerFechaSync": null
}</GetEmpresasJsonResult></GetEmpresasJsonResponse></soap:Body></soap:Envelope>

What i'm doing bad?

Thanks. Regards

bubudrc
  • 159
  • 4
  • 11
  • possible duplicate of [Use AFNetworking + use soap web service + how to make request?](http://stackoverflow.com/questions/21308227/use-afnetworking-use-soap-web-service-how-to-make-request) – Paresh Navadiya Apr 07 '14 at 19:00
  • http://jayprakashdubey.blogspot.in/2014/09/invoke-soap-web-service.html – Jayprakash Dubey Sep 30 '14 at 12:57

1 Answers1

-5

The problem was not the call... instead was the parameter: @"0035", because, the server needed a json parameter with all the values to proccess the request correctly, I mean, e.g:

{
"companyid":"0035",
}
Matthew Darnell
  • 4,538
  • 2
  • 19
  • 29
bubudrc
  • 159
  • 4
  • 11