1

Advance thanks, I am trying soap request from last 3 days i did all the way finally i come with this sol: Soap response i am getting

   UserInfo={_kCFURLErrorAuthFailedResponseKey=<CFURLResponse 0x6000002e8780 [0x10af95df0]>{url = http://xx.xxx.xxx.xx:xxx/xxx/xx/CLF%20Distribution%20Live/Codeunit/WarehouseManagement}

i try:

NSString *theUserName = @"xxxxx";

NSString *thePassword = @"xxxxx";
NSString *theDomain = @"xxxxx";

NSString *soapMessage = [NSString stringWithFormat:@"Xml"];

NSURL *url = [NSURL URLWithString:@"http://xx.xxx.xxx.xx:xxx/xx/xx/xx"];

 NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
 NSString *msgLength = [NSString stringWithFormat:@"%lu", (unsigned long)[soapMessage length]];

 [theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
 [theRequest addValue:@"urn:microsoft-dynamics-schemas/codeunit/WarehouseManagement:GfncValidatePassword" forHTTPHeaderField:@"SOAPAction"];
 [theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
 [theRequest setHTTPMethod:@"POST"];
 [theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
NSData *authData = [authStr dataUsingEncoding:NSUTF8StringEncoding];
NSString *authValue = [NSString stringWithFormat:@"Basic %@", [authData base64EncodedStringWithOptions:0]];
[theRequest setValue:authValue forHTTPHeaderField:@"Authorization"];

NSData *webData = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:&response error:&error];

  • You missing the creation of `authStr`! – Libin Varghese Mar 21 '17 at 18:19
  • Here is how you have to prepare HTTP Header Field: http://stackoverflow.com/questions/1973325/nsurlconnection-and-basic-http-authentication-in-ios – Nazir Mar 21 '17 at 18:22
  • thanks Lot – Nazir i try that not usefull – user3518618 Mar 21 '17 at 18:48
  • Thanks – Libin Varghese authStr i created thats Not i my case i try with this NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; Error: status code: 401, headers { Connection = close; "Content-Length" = 0; Date = "Tue, 21 Mar 2017 18:39:51 GMT"; Server = "Microsoft-HTTPAPI/2.0"; "Www-Authenticate" = Negotiate; – user3518618 Mar 21 '17 at 18:52
  • i have doubts in this line NSString *authStr = [NSString stringWithFormat:@"%@:%@:%@", theUserName, thePassword,theDomain]; - sorry i forgot to this this line above code – user3518618 Mar 21 '17 at 18:57
  • got solution for this problem I am not change anything in my code server side changes are made I told then to update here.... this may help please check your api in postman... – user3518618 Mar 27 '17 at 17:58

0 Answers0