1
2012-07-27 20:15:53.523 ProjectDemo[1697:40b] Done. received Bytes 0
2012-07-27 20:15:53.524 ProjectDemo[1697:40b] the xml Data is

NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%d",[soapMessage length]];
[theRequest addValue:@"text/xml" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue:@"ManageCase" forHTTPHeaderField:@"SOAPAction"];
[theRequest addValue:msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody:[soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];

我从肥皂信封得到的响应是 0。

任何人都可以建议我在什么情况下响应将为 0。

@提前致谢

4

1 回答 1

1

尝试使用 "text/xml; charset=utf-8" 作为您的 Content-Type 标头字段值。

还可以尝试将整个命名空间包含在 SOAPAction 标头中,例如“http://www.yournamespace.com/ManageCase”

这是一个 SOAP 1.1 Objective-C 代码示例:

NSString *soapAction = @"Login";
NSString *messageLength = [NSString stringWithFormat:@"%d", [message length]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:serverURL];
[request addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[request addValue:[NSString stringWithFormat:@"http://www.namespace.com/%@", soapAction] forHTTPHeaderField:@"SOAPAction"];
[request addValue:messageLength forHTTPHeaderField:@"Content-Length"];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:[message dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
于 2012-07-27T20:56:50.220 回答