.net 웹 서비스에 SOAP 요청을 보내는 동안 오류가 발생합니다. 여기에 뭔가 누락 되었습니까?
NSString *str1 = [NSString stringWithFormat:@"<UserId>%@</UserId><Password>%@</Password><Referal>%@</Referal>",u,p,r];
NSString *soapMessage = [NSString stringWithFormat: @"<?xml version=\"1.0\" \encoding=\"utf-8\"?>" "<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/\">""<soap:Body>""<getData xmlns=\"http://tempuri.org/\">\n"" <reqXML>%@</reqXML>""</getData>\n""</soap:Body>""</soap:Envelope>", str1];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
[theRequest setHTTPMethod:@"POST"];
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMessage length]];
[theRequest addValue: @"application/soap+xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
나는 사용하고있다
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:theRequest];
내가 얻는 오류는 다음과 같습니다.
Error Domain=com.alamofire.networking.error Code=-1011 "Expected status code in (200-299), got 400" UserInfo=0x7536290 {NSErrorFailingURLKey=http://213.171.205.156/webservice_booking_affiliate_live/bookingengine.asmx, NSLocalizedDescription=Expected status code in (200-299), got 400}
400이 잘못된 요청이라는 것을 알고 있습니다. 추가해야 할 것이 있습니까?
.net 서비스의 경우 Android와 같은 다른 항목을 보내야합니까? soapobject.dotnet = true
친구가 답을 찾았습니다 :::
soap : body 내에서 XML을 전송하는 동안 때때로 문제가 발생합니다. 이 문제를 해결하기위한 빠르고 더러운 해결책은 다음과 같이 CDATA 섹션에 xml (온도 또는 통화 코드 등과 같이 전달하려는 매개 변수 만)을 래핑하는 것입니다.
<![CDATA[%@]]>. This would mean that the XML parser will not parse that section.
대부분의 블로그에 따르면이 방법만으로도 효과가 있지만 효과가 없다면
replace the < and > with "<" and ">".
그래도 작동하지 않으면 액세스 권한이 있으면 웹 서비스에서 다시 변경하십시오.
query = [query stringByReplacingOccurrencesOfString:@"<" withString:@"<"];
query = [query stringByReplacingOccurrencesOfString:@">" withString:@">"];
친구를 건배 해주셔서 감사합니다 ... ATB
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다