2014-05-23 74 views
0

我要發佈使用afnetworking此服務的一些數據,它的內容類型是application /肥皂+ xml.but我得到了錯誤AFNetworking POST和GET XML數據

Error Domain=AFNetworkingErrorDomain Code=-1011 "Request failed: internal server error (500)" UserInfo=0x9034f00 {NSErrorFailingURLKey=http://webapp.admin-inapp.com/services/FeedbackService.asmx?op=SendFeedback, AFNetworkingOperationFailingURLResponseErrorKey=<NSHTTPURLResponse: 0x8e31a00> { URL: http://webapp.admin-inapp.com/services/FeedbackService.asmx?op=SendFeedback } { status code: 500, headers { 
"Cache-Control" = private; 
"Content-Length" = 1666; 
"Content-Type" = "application/soap+xml; charset=utf-8"; 
Date = "Fri, 23 May 2014 06:43:32 GMT"; 
Server = "Microsoft-IIS/8.0"; 
"X-AspNet-Version" = "4.0.30319"; 
"X-Powered-By" = "ASP.NET"; 

}},NSLocalizedDescription =請求失敗:內部服務器錯誤(500)}

這裏是我的代碼

NSString *string = [NSString stringWithFormat:@"http://webapp.admin-inapp.com/services/FeedbackService.asmx?op=SendFeedback"]; 
NSMutableDictionary *dict = [[NSMutableDictionary alloc]init]; 
[dict setObject:@"9888291933" forKey:@"Number"]; 
[dict setObject:self.textview.text forKey:@"Feedback"]; 
AFHTTPRequestOperationManager * manager = [AFHTTPRequestOperationManager manager]; 

[manager POST:string parameters:dict success:^(AFHTTPRequestOperation *operation, id responseObject) { 
    NSLog(@"%@",responseObject); 
} failure:^(AFHTTPRequestOperation *operation, NSError *error) { 
    NSLog(@"%@",error); 
}]; 

}

+0

檢查此鏈接http://stackoverflow.com/questions/20402034/parsing-xml-with-afnetworking –

+0

500錯誤表示出事了服務器處理您的請求.. – GoodSp33d

+0

您可以發送您所要求的網址是什麼? – PREMKUMAR

回答

0

請檢查您的網址和對象。

我認爲這是SOAP Web服務。您必須以不同的方式發送SOAP Web服務的請求。

NSString *soapMessage = [NSString stringWithFormat: 
        @"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" 
        "<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/\">\n" 
        "<soap:Body>\n" 
        "<YourServiceName xmlns=\"http://tempuri.org/\">\n" 
        "<Number>1001010</Number>\n" 
        "<Feedback>Something feedback</Feedback>\n" 
        "</YourServiceName>\n" 
        "</soap:Body>\n" 
        "</soap:Envelope>\n", Number, Feedback 
        ]; 

        NSURL *url = [NSURL URLWithString:@"http://webapp.admin-inapp.com/services/FeedbackService.asmx?op=SendFeedback"]; 
        NSMutableURLRequest *theRequest = [NSMutableURLRequest  requestWithURL:url]; 
        NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]]; 
       [theRequest addValue: @"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"]; 
    [theRequest addValue: [NSString stringWithFormat:@"http://tempuri.org/%@",service] forHTTPHeaderField:@"SOAPAction"]; 
    [theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"]; 
    [theRequest setHTTPMethod:@"POST"]; 
[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]]; 
[theRequest setTimeoutInterval:10]; 
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; 

if(theConnection) 
{ 
responseData = [[NSMutableData data] retain]; 
} 
else 
{ 
NSLog(@"theConnection is NULL"); 
} 
+0

用戶名和密碼? – Rana

+0

不好意思小改動。現在檢查 – PREMKUMAR