Ios svcwebservice-objective-c

Ios svcwebservice-objective-c,ios,objective-c,wcf,svc,Ios,Objective C,Wcf,Svc,&发现它非常有用,但当我开始尝试所有可能的方法时,我未能获得所需的输出 NSString *soapMessage = [NSString stringWithFormat: @"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" "<SOAP:Envelope xmlns:s=\"http://schemas.xmlsoap.org/so

&发现它非常有用,但当我开始尝试所有可能的方法时,我未能获得所需的输出

NSString *soapMessage = [NSString stringWithFormat:
                         @"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
                         "<SOAP:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"
                         "<SOAP:Body>\n"
                         "<BindCategory xmlns=\"http://tempuri.org/\">\n"
                         "</SOAP:Body>\n"
                         "</SOAP:Envelope>\n"
                         ];

NSLog(@"soapMessage: \n%@",soapMessage);

NSURL *url = [NSURL URLWithString:@"http://assetwebservice.sudesi.in/Service/"];

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://tempuri.org/IService/BindCategory" forHTTPHeaderField:@"SOAPAction"];
[theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
NSString*soapMessage=[NSString stringWithFormat:
@“\n”
“\n”
“\n”
“\n”
“\n”
“\n”
];
NSLog(@“soapMessage:\n%@”,soapMessage);
NSURL*url=[NSURL URLWithString:@”http://assetwebservice.sudesi.in/Service/"];
NSMutableURLRequest*theRequest=[NSMutableUrlRequestWithURL:url];
NSString*msgLength=[NSString stringWithFormat:@“%d”,[soapMessage length]];
[theRequest addValue:@“text/xml;charset=utf-8”用于HttpHeaderField:@“Content Type”];
[请求附加值:@”http://tempuri.org/IService/BindCategoryforHTTPHeaderField:@“SOAPAction”];
[theRequest addValue:msgLength for HttpHeaderField:@“内容长度”];
[TheRequestSetHttpMethod:@“POST”];
[TheRequestSetHttpBody:[soapMessage数据使用编码:NSUTF8StringEncoding];
我想我一定是犯了点小错误。我得到以下输出

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>404 (Page Not Found) Error - Ever feel like you're in the wrong place?</title>
<link href="http://p3nlhclust404.shr.prod.phx3.secureserver.net/SharedContent/404-etc-styles.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<body>
    <div class="body-404">
        <h1>
            <span>Ever feel you're in the wrong place</span>
        </h1>
        <div class="info-container">
            <div class="inner-border clear-fix">
                <h2 class="info-top">
                    404 (Page Not Found) Error
                </h2>
                <div class="site-owner-404">
                    <h3>If you're the <strong>site owner,</strong> one of two things happened:</h3>
                    <ol>
                        <li>
                            1) You entered an incorrect URL into your browser's address bar, or
                        </li>
                        <li>
                            2) You haven't uploaded content.
                        </li>
                    </ol>
                </div>      
                <div class="site-visitor-404">
                    <h3>If you're a <strong>visitor</strong> and not sure what happened:</h3>
                    <ol>
                        <li>
                            1) You entered or copied the URL incorrectly or
                        </li>
                        <li>
                            2) The link you used to get here is faulty.
                        </li>
                        <li class="last">
                            (It's an excellent idea to let the link owner know.)
                        </li>
                    </ol>
                </div>
            </div>
        </div>
    </div>
</body>
</html>

404(找不到页面)错误-有没有觉得你在错误的地方?
你有没有觉得你来错地方了
404(找不到页面)错误
如果您是网站所有者,发生了以下两件事之一:
  • 1) 您在浏览器的地址栏中输入了错误的URL,或者
  • 2) 你还没有上传内容。
  • 如果您是访客,但不确定发生了什么:
  • 1) 您输入或复制的URL不正确或错误
  • 2) 你在这里使用的链接有问题。
  • (最好让链接所有者知道。)
  • 谁能帮助我理解我做错了什么?
    非常感谢您的帮助?

    我找到了解决方案:soap消息中的第二行已更正

    "<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"
    
    “\n”
    “\n”
    
    url字符串中也缺少.svc扩展名。我用声明更正了它。 很好地看到,s from service.svc是小写,而在soapaction参数中是大写

    下面是带有http头参数的整个soap消息

    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"
                             "<BindCategory xmlns=\"http://tempuri.org/\">\n"
                             "</BindCategory>\n"
                             "</soap:Body>\n"
                             "</soap:Envelope>\n"
                             ];
    NSLog(@"soapMessage: \n%@",soapMessage);
    
    NSURL *url = [NSURL URLWithString:@"http://assetwebservice.sudesi.in/service.svc"];    
    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://tempuri.org/IService/BindCategory" forHTTPHeaderField:@"soapaction"];
    [theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"];
    [theRequest setHTTPMethod:@"POST"];
    [theRequest setHTTPBody: [soapMessage dataUsingEncoding:NSUTF8StringEncoding]];
    
    NSString*soapMessage=[NSString stringWithFormat:
    @“\n”
    “\n”
    “\n”
    “\n”
    “\n”
    “\n”
    “\n”
    ];
    NSLog(@“soapMessage:\n%@”,soapMessage);
    NSURL*url=[NSURL URLWithString:@”http://assetwebservice.sudesi.in/service.svc"];    
    NSMutableURLRequest*theRequest=[NSMutableUrlRequestWithURL:url];
    NSString*msgLength=[NSString stringWithFormat:@“%d”,[soapMessage length]];
    [theRequest addValue:@“text/xml;charset=utf-8”用于HttpHeaderField:@“Content Type”];
    [请求附加值:@”http://tempuri.org/IService/BindCategoryforHTTPHeaderField:@“soapaction”];
    [theRequest addValue:msgLength for HttpHeaderField:@“内容长度”];
    [TheRequestSetHttpMethod:@“POST”];
    [TheRequestSetHttpBody:[soapMessage数据使用编码:NSUTF8StringEncoding];
    
    有一件事仍然让我困惑,那就是即使是GET请求,当我将其更改为POST时,它也会向我抛出“连接错误”
    NSLog
    &并成功