开发者

Server did not recognize the value of HTTP Header SOAPAction in iPhone?

I am try to connect webservices to my code i got error as

"Server did not recognize the value of 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"
                         "<Hello xmlns=\"http://viium.com/\">\n"
                         "<name>%@</name>\n"
                         "</Hello>\n"
                         "</soap:Body>\n"
                         "</soap:Envelope>\n", @"new"
                     开发者_如何学JAVA    ];
NSLog(soapMessage);

NSURL *url = [NSURL URLWithString:@"http://viium.com/WebService/HelloWorld.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://viium.com/Hello" forHTTPHeaderField:@"SOAPAction"];
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];

Please guide me what iam missing?


NSURL *url = [NSURL URLWithString:@"https://servername.com/WebService/WebServicename.asmx"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
NSString *msgLength = [NSString stringWithFormat:@"%d",[soapMessage length]];
[theRequest addValue:@"text/xml" forHTTPHeaderField:@"Content-Type"];
[theRequest addValue:@"servername.com/Hello" forHTTPHeaderField:@"SOAPAction"];
[theRequest addValue:msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody:[soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection  *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];

here is the link,

http://abhicodehelp.blogspot.com/2010/12/handling-soap-with-iphone.html

this may help you..


If it's your own web-service, check whether your "servername.com/Hello" in query equals namespace in Web-Service.

In ASP.Net it defines like:

[WebService(Namespace="servername.com/Hello")]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜