Objective c 在xml soap响应上获取错误

Objective c 在xml soap响应上获取错误,objective-c,web-services,soap,Objective C,Web Services,Soap,使用iphone向webservice soap发送请求时出错。我怎样才能修好它 这是我得到的信息 <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/

使用iphone向webservice soap发送请求时出错。我怎样才能修好它

这是我得到的信息

<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
  <soap:Fault>
     <faultcode>soap:Client</faultcode>
     <faultstring>Server did not recognize the value of HTTP Header SOAPAction: HelloWorld.</faultstring>
      <detail />
   </soap:Fault>
 </soap:Body>
 </soap:Envelope>

soap:客户端
服务器无法识别HTTP标头SOAPAction:HelloWorld的值。
这是我的objective-c代码

-(IBAction)buttonClick:(id)sender
{
recordResults = FALSE;

NSString *soapMsg =
[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"
 "<HelloWorld xmlns=\"http://tempuri.org/\" />\n"
 "</soap:Body>\n"
 "</soap:Envelope>\n"];

//---print it to the Debugger Console for verification---
NSLog(soapMsg);

NSURL *url = [NSURL URLWithString: @"http://servicing2.rotanet.com.tr/service1.asmx"];
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:req delegate:self];

//---set the various headers---
NSString *msgLength = [NSString stringWithFormat:@"%d", [soapMsg length]];
[req addValue:@"text/xml; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
[req addValue:@"HelloWorld" forHTTPHeaderField:@"SOAPAction"];
[req addValue:msgLength forHTTPHeaderField:@"Content-Length"];

//---set the HTTP method and body---
[req setHTTPMethod:@"POST"];
[req setHTTPBody:[soapMsg dataUsingEncoding:NSUTF8StringEncoding]];


theConnection = [[NSURLConnection alloc] initWithRequest:req delegate:self];
if (theConnection) {
    webData = [[NSMutableData data] retain];
}
}
-(iAction)按钮单击:(id)发件人
{
记录结果=假;
NSString*soapMsg=
[NSString stringWithFormat:
@“\n”
“\n”
“\n”
“\n”
“\n”
“\n”];
//---将其打印到调试器控制台进行验证---
NSLog(soapMsg);
NSURL*url=[NSURL URLWithString:@”http://servicing2.rotanet.com.tr/service1.asmx"];
NSMutableURLRequest*req=[NSMutableUrlRequestWithURL:url];
NSURLConnection*连接=[[NSURLConnection alloc]initWithRequest:req委托:self];
//---设置各种标题---
NSString*msgLength=[NSString stringWithFormat:@“%d”,[soapMsg长度]];
[req addValue:@“text/xml;charset=utf-8”用于httpheaderfield:@“Content Type”];
[req addValue:@“HelloWorld”用于HttpHeaderField:@“SOAPAction”];
[req addValue:msgLength for HttpHeaderField:@“内容长度”];
//---设置HTTP方法和正文---
[req setHTTPMethod:@“POST”];
[req setHTTPBody:[soapMsg dataUsingEncoding:NSUTF8StringEncoding]];
连接=[[NSURLConnection alloc]initWithRequest:req委托:self];
if(连接){
webData=[[NSMutableData]保留];
}
}

我已经为此工作了两天。我快疯了。你们有什么建议吗?

服务器无法找到与您发送的请求相对应的服务。您创建的SOAP事务发送:

"<HelloWorld xmlns=\"http://tempuri.org/\" />\n"
看起来您的SOAP客户机还不错,只是操作
HelloWorld
与服务器上的任何内容都不对应


检查服务器并确保该操作有效,然后更正客户端以发送有效的操作请求,或者更正服务器以响应您发送的请求。

服务器无法找到与您发送的请求相对应的服务。您创建的SOAP事务发送:

"<HelloWorld xmlns=\"http://tempuri.org/\" />\n"
看起来您的SOAP客户机还不错,只是操作
HelloWorld
与服务器上的任何内容都不对应


检查服务器并确保这是一个有效的操作,然后更正客户端以发送有效的操作请求,或者更正服务器以响应您发送的请求。

我认为您通过了错误的操作

试试这个

[req addValue:@"http://tempuri.org/HelloWorld" forHTTPHeaderField:@"SOAPAction"]

我认为你采取了错误的行动

试试这个

[req addValue:@"http://tempuri.org/HelloWorld" forHTTPHeaderField:@"SOAPAction"]
取而代之的是,

[req addValue: @"http://tempuri.org/HelloWorld [req addValue:@"HelloWorld" forHTTPHeaderField:@"SOAPAction"];" forHTTPHeaderField:@"SOAPAction"];
而不是

[req addValue:@"HelloWorld" forHTTPHeaderField:@"SOAPAction"];
取而代之的是,

[req addValue: @"http://tempuri.org/HelloWorld [req addValue:@"HelloWorld" forHTTPHeaderField:@"SOAPAction"];" forHTTPHeaderField:@"SOAPAction"];
而不是

[req addValue:@"HelloWorld" forHTTPHeaderField:@"SOAPAction"];