我正在做肥皂請求/響應應用程序。在構建SOAP響應時,我得到「服務器無法識別HTTP Header SOAPAction的值」。肥皂響應錯誤
這是什麼意思?以及如何解決這個問題?
這是代碼。
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"
"<SignOn xmlns=\"http://10.12.50.99/CUTechWebservices/CuTechWebService.asmx\">\n"
"<DeviceID>4A6B740C-0B5B-5F8C-8694-1EC0196C1C67</DeviceID>\n"
"<UserID>10827</UserID>\n"
"<CrID>6</CrID>\n"
"<UserPin>777777!</UserPin>\n"
"</SignOn>\n"
"</soap:Body>\n"
"</soap:Envelope>\n"];
NSLog(@"%@",soapMessage);
//Soap request.
NSURL *url = [NSURL URLWithString:@"https://mobile.areafinancial.com/cutechservice/cutechwebservice.asmx"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%d",[soapMessage length]];
[theRequest addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue:@"http://10.12.50.99/CUTechWebservices/CuTechWebService.asmx" forHTTPHeaderField:@"SOAPAction"];
[theRequest addValue:msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody:[soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
我試過了。但是這次我收到錯誤「無法處理請求,操作'https://mobile.areafinancial.com/cutechservice/cutechwebservice.asmx?op=SignOn''無法識別。」 –
嘗試'http:// 10.12.50.99/CUTechWebservices/CuTechWebService.asmx/SignOn'作爲操作。我通過下載https://mobile.areafinancial.com/cutechservice/cutechwebservice.asmx?WSDL並搜索soapAction字符串來發現它。 –
@peter,這是我真正做到的。它的工作完美。謝謝你的幫助 –