SVC webservice - objective-c [英] SVC webservice - objective-c

查看:136
本文介绍了SVC webservice - objective-c的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我推荐此链接&发现它非常有用但是当我开始尝试它的每一个可能时,我都没能得到所需的输出。

I referred this link & found it very useful but when I started trying every possible of it I failed in getting the desired output.

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]];

我想我一定是在犯一些小错误。我得到以下输出。

I think I must be doing some minor mistake. I am getting following output.

<!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>

有人可以帮助理解我在做什么错吗?
非常感谢任何帮助?

Can anybody help to understand what wrong I am doing? Any help is greatly appreciated?

推荐答案

嘿,伙计们找到了解决方案。
更正了肥皂信息中的第二行。

Hey guys found out the solution. The second line in the soap message corrected.

"<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"

同样在url字符串中.svc扩展名也丢失了。我用声明纠正了它。
http://assetwebservice.sudesi.in/service.svc
请参阅service.svc中的s是小写,而在soapaction参数中它是大写。

Also in the url string .svc extension was missing. I corrected it with the statement. http://assetwebservice.sudesi.in/service.svc See well the s from service.svc is lower case whereas in soapaction parameter it is upper case.

以下是带有http的整个soap消息标头参数。

Below is the entire soap message with http header parameters.

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]];

有一件事让我感到困惑的是,即使它是一个GET请求,它也会让我失望连接中的错误 NSLog &当我将其更改为POST

One thing still confuse me is that even if it is a GET request it throws me "ERROR in Connection" NSLog & succeeds when I change it to POST

这篇关于SVC webservice - objective-c的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆