2

This is my first time to make a SOAP Request using AFNetworking 2.0 I don't know what the problem is but I really couldn't make a correct web service call.

Using SOAP UI, this is the Request Format

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
   <soapenv:Header>
      <tem:Username>myHeaderUserName</tem:Username>
      <tem:Password>myHeaderHashedPassword</tem:Password>
   </soapenv:Header>
   <soapenv:Body>
      <tem:GetDailyTaskLogRequest>
         <tem:Day>7/23/2014</tem:Day>
         <tem:DeliverableID>0</tem:DeliverableID>
         <tem:GetFirstTimeIn>false</tem:GetFirstTimeIn>
         <tem:MileStoneID>0</tem:MileStoneID>
         <tem:OtherFilterType></tem:OtherFilterType>
         <tem:OtherFilterValue>0</tem:OtherFilterValue>
         <tem:ProjectCode></tem:ProjectCode>
         <tem:SubProjectID>0</tem:SubProjectID>
         <tem:TaskType>Active</tem:TaskType>
         <tem:UserName>myBodyUsername</tem:UserName>
      </tem:GetDailyTaskLogRequest>
   </soapenv:Body>
</soapenv:Envelope>

So what I did, inside the method for web service call in my iOS App is

 NSString *soapMessage = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
                             "soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:tem=\"http://tempuri.org/\">"
                             "<soap:Body>"
                             "<tem:GetDailyTaskLogRequest>"

                             "<tem:Day>7/23/2014</tem:Day>"

                             "<tem:DeliverableID>0</tem:DeliverableID>"

                             "<tem:GetFirstTimeIn>false</tem:GetFirstTimeIn>"

                             "<tem:MileStoneID>0</tem:MileStoneID>"

                             "<tem:OtherFilterType></tem:OtherFilterType>"

                             "<tem:OtherFilterValue>0</tem:OtherFilterValue>"

                             "<tem:ProjectCode></tem:ProjectCode>"

                             "<tem:SubProjectID>0</tem:SubProjectID>"

                             "<tem:TaskType>Active</tem:TaskType>"

                             "<tem:UserName>myUserName</tem:UserName>"
                             "</tem:GetDailyTaskLogRequest>"
                             "</soap:Body>"
                             "</soap:Envelope>"];

NSURL *url = [NSURL URLWithString:];
    NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
        [theRequest addValue: @"myHeaderUserName" forHTTPHeaderField:@"Username"];
        [theRequest addValue: @"myHeaderHashedPassword" forHTTPHeaderField:@"Password"];
        [theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];

    [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    manager.responseSerializer = [AFXMLParserResponseSerializer serializer]; // if response XML format
    [manager POST:@"" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {

        NSLog(@"SUCCESS RESPONSE: %@", responseObject);
        [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {

        NSLog(@"ERROR RESPONSE: %@", error);
        [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
    }];

Actually, I think my problem really here is how to format the correct Soap Request that will access and supply the required parameters, which are: I should have pass valid UserName and Password on the Header of the Request, also, I should have pass valid parameter values (Day, DeliverableID, GetFirstTimeIn, etc...) within within the Soap Body.

What am I doing wrong? Because when I run this, I;m getting an error response:

ERROR RESPONSE: Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: bad request (400)" UserInfo=0x1094a91f0 {com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x10940d620> { URL: myURLString } { status code: 400, headers {
    "Cache-Control" = private;
    "Content-Length" = 0;
    Date = "Thu, 24 Jul 2014 07:42:48 GMT";
    Server = "Microsoft-IIS/6.0";
    "X-AspNet-Version" = "4.0.30319";
    "X-Powered-By" = "ASP.NET";
} }, NSLocalizedDescription=Request failed: bad request (400), NSErrorFailingURLKey=myURLString}

(Note: I edited the error response, just hide my actual urlString with the myURLString var)

  • the error is from DB side. And if you have find the solution for your problem have you ever tried posting an image using the same format as above. If so pls help me http://stackoverflow.com/questions/29077775/upload-image-from-iphone-to-server-using-wcf-service-using-soap – sreekanthk Mar 17 '15 at 06:44
  • you could try this http://stackoverflow.com/a/21308267/730807 – Durai Amuthan.H Mar 22 '15 at 19:17

0 Answers0