Ios AFN发布并获取xml数据
我想使用afnetworking发布一些关于这个服务的数据,其内容类型是application/soap+xmlIos AFN发布并获取xml数据,ios,objective-c,afnetworking-2,Ios,Objective C,Afnetworking 2,我想使用afnetworking发布一些关于这个服务的数据,其内容类型是application/soap+xml Error Domain=AFNetworkingErrorDomain Code=-1011 "Request failed: internal server error (500)" UserInfo=0x9034f00 {NSErrorFailingURLKey=http://webapp.admin-inapp.com/services/FeedbackService.asm
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";
}请检查您的URL和对象 我认为这是soapweb服务。您必须以不同的方式发送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");
}
NSString*soapMessage=[NSString stringWithFormat:
@“\n”
“\n”
“\n”
“\n”
“1001010\n”
“一些反馈信息\n”
“\n”
“\n”
“\n”、编号、反馈
];
NSURL*url=[NSURL URLWithString:@”http://webapp.admin-inapp.com/services/FeedbackService.asmx?op=SendFeedback"];
NSMutableURLRequest*theRequest=[NSMutableUrlRequestWithURL:url];
NSString*msgLength=[NSString stringWithFormat:@“%d”,[soapMessage length]];
[theRequest addValue:@“text/xml;charset=utf-8”用于HttpHeaderField:@“Content Type”];
[theRequest addValue:[NSString stringWithFormat:@]http://tempuri.org/%@,服务]用于HttpHeaderField:@“SOAPAction”];
[theRequest addValue:msgLength for HttpHeaderField:@“内容长度”];
[TheRequestSetHttpMethod:@“POST”];
[TheRequestSetHttpBody:[soapMessage数据使用编码:NSUTF8StringEncoding];
[TheRequestSetTimeOutInterval:10];
NSURLConnection*连接=[[NSURLConnection alloc]initWithRequest:theRequest委托:self];
if(连接)
{
responseData=[[NSMutableData]retain];
}
其他的
{
NSLog(@“连接为空”);
}
检查此链接500错误表示服务器处理您的请求时出错。您能发送您请求的URL吗?它会给我相同的错误。请在此处共享您请求的URL用户名和密码?很抱歉,有小改动。现在检查
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");
}