肥皂反应错误

时间:2011-07-06 12:05:07

标签: iphone

我正在做肥皂请求/响应应用程序。在构建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]];

2 个答案:

答案 0 :(得分:1)

在SOAP 1.2中SOAPAction标头已替换为action标头字段的“可选”Content-Type属性。

使用以下标题尝试:

Content-Type: application/soap+xml; charset=utf-8; action="https://mobile.areafinancial.com/cutechservice/cutechwebservice.asmx?op=SignOn"

没有SOAPAction:标题字段。

另见http://www.coderanch.com/t/224524/Web-Services/java/SOAPAction-header

答案 1 :(得分:0)

尝试删除下面的行,看看你得到了什么。您在请求中传递的标头。您应该传递与Web服务中相同的标头。

[theRequest addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];