2013-11-20 2 views
-2

내 응용 프로그램에서는 AFNetworking을 사용하여 서비스를 구문 분석합니다. 여기에 서버에 이미지를 게시해야하므로 이미지를 게시하려 할 때 오류 메시지 아래에 응답으로 표시됩니다. 여기 AFNetworking을 사용하여 이미지를 게시하는 방법은 무엇입니까?

내 코드입니다 :

NSString *urlString = [NSString stringWithFormat:@"http://www.xyz.com:8084/TappyokaCmsService/Service.svc"]; 

NSString *path=[NSString stringWithFormat:@"/InsertUserInfo?User_Name=%@&User_Pwd=%@&User_FName=%@&User_LName=%@&User_Mail=%@&User_Phno=%@&User_Address=%@&User_Dob=%@&Ic_No=%@&User_Active=%@&User_Questions=%@&User_Ans=%@&ImageUrl=%@&IsSocial=%@",@"skull",@"skull",@"skull",@"skull",@"skull",@"skull",@"skull",@"skull",@"skull",@"10001",@"skull",@"skull",@"",@"10001"]; 

AFHTTPClient *httpClient= [AFHTTPClient clientWithBaseURL:[NSURL URLWithString:urlString]]; [httpClient registerHTTPOperationClass:[AFJSONRequestOperation class]]; [AFJSONRequestOperation addAcceptableContentTypes:[NSSet setWithObject:@"text/html"]]; NSMutableURLRequest *request = [httpClient multipartFormRequestWithMethod:@"POST" path:path parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) { 
[formData appendPartWithFileData:imageToUpload name:@"skull" fileName:@"skull.jpg" mimeType:@"image/jpg"]; 
}]; 

    // You can add then the progressBlock and the completionBlock 
    AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; 

    [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) 
    { 
     NSDictionary *jsons = [NSJSONSerialization JSONObjectWithData:responseObject options:kNilOptions error:nil]; 
     NSLog(@"response: %@",jsons); 

    } 
    failure:^(AFHTTPRequestOperation *operation, NSError *error) 
    { 
     if([operation.response statusCode] == 403) 
     { 
      NSLog(@"Upload Failed"); 
      return; 
     } 
     NSLog(@"error: %@", [operation error]); 

    }]; 

    [operation start]; 

그리고 오류 메시지는 다음과 같습니다

Status code: 404, headers { 
"Content-Length" = 1245; 
"Content-Type" = "text/html"; 
Date = "Wed, 20 Nov 2013 15:04:17 GMT"; 
Server = "Microsoft-IIS/7.5"; 
"X-Powered-By" = "ASP.NET" 

답변

0

404 오류 404 오류는 당신이 뭔가에 액세스하려고에 의해 발생

서버에서 찾을 수없는 웹 서비스, 즉 잘못된 URL을 호출하고 있습니다.

문서 당신이 사진을 업로드하기 위해 웹 서비스와 상호 작용하는 방법에 대한 몇 가지 문서가 희망이

, 내가 가진 내가 틀리지 않는 경우 (잘못을하고있는 느낌 SOAP 요청을해야합니까?).

+0

클리어리 plz를 설명 할 수 있습니까? – user2230971

+0

@ user2230971 내 대답을 편집했지만, 내가 가진 것보다 훨씬 명확하게 말할 수는 없습니다. – NinjaLikesCheez

관련 문제