当前位置:  开发笔记 > IOS > 正文

如何为ipad发送/接收带有目标c的肥皂对象

如何解决《如何为ipad发送/接收带有目标c的肥皂对象》经验,为你挑选了0个好方法。

我一直在尝试为ipad编写一个目标C应用程序,以发送/接收Soap Web服务。我已经写了一个代码,但是它给出了一个错误。该Web服务正在在线工作。

这是我的代码,

-(IBAction)invokeService
{

    [txt1 resignFirstResponder];

    NSString *soapFormat = [NSString stringWithFormat:
                    @"\n"
                    "\n"
                    "\n"
                    "\n"
                    "\n"
                    "\n"];


    NSLog(@"The request format is %@",soapFormat);

    NSURL *locationOfWebService = [NSURL URLWithString:@"http://servicing2.rotanet.com/service1.asmx"];

    NSLog(@"web url = %@",locationOfWebService);

    NSMutableURLRequest *theRequest = [[NSMutableURLRequest alloc]initWithURL:locationOfWebService];

    NSString *msgLength = [NSString stringWithFormat:@"%d",[soapFormat length]];

    [theRequest addValue:@"text/xml" forHTTPHeaderField:@"Content-Type"];
    [theRequest addValue:@"GetUserList" forHTTPHeaderField:@"SOAPAction"];
    [theRequest addValue:msgLength forHTTPHeaderField:@"Content-Length"];
    [theRequest setHTTPMethod:@"POST"];
    //the below encoding is used to send data over the net
    [theRequest setHTTPBody:[soapFormat dataUsingEncoding:NSUTF8StringEncoding]];


    NSURLConnection *connect = [[NSURLConnection alloc]initWithRequest:theRequest delegate:self];

    if (connect) {
        webData = [[NSMutableData alloc]init];
        startActivityIndicator;
    }
    else {
        NSLog(@"No Connection established");
    }
}

我收到此错误消息

  soap:ClientSystem.Web.Services.Protocols.SoapException:  Server did not recognize the value of HTTP Header SOAPAction: GetUserList.
at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()
at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message)
at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
at System.Web.Services.Protocols.ServerProtocol.SetContext(Type type, HttpContext context, HttpRequest request, HttpResponse response)
at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)  

我究竟做错了什么?

推荐阅读
mylvfamily
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有