2013-04-09 127 views
-1

我是iPhone开发新手,想要获得答案,请发送带有用户名,密码和公司ID的肥皂标题的请求。如何使用ObjC在ios中发送此Soap Header请求?

我已经搜索了很多教程,但没有任何帮助。

在此先感谢。

肥皂代码是:

<soap:Header> 
<AuthenticationData xmlns="http://www.harikishan.com/"> //www.harikishan.com used as an example of website to which i need to send request 
    <CompanyId>string</CompanyId> 
    <UserName>string</UserName> 
    <Password>string</Password> 
</AuthenticationData> 
</soap:Header> 
+0

这不是一个好问题。你应该先尝试一些事情,当你面临问题时,而不是随问题而来。 http://highoncoding.com/Articles/809_Consuming__NET_Web_Services_in_an_iOS_Application.aspx,http://www.macresearch.org/interacting-soap-based-web-services-cocoa-part-2,http://www.makebetterthings.com/ iphone /呼叫SOAP的Web服务 - 从 - iphone /。 http://mattgemmell.com/2008/12/08/what-have-you-tried/ – CRDave 2013-04-09 11:01:36

+1

@CRDave ,,,我在这方面做了大量的研究,但从现在起,我会付出更多的努力,然后再问其他任何东西, – 2013-04-10 05:36:30

回答

0

你需要做一个nnstring你肥皂身体

创建3串companyID,用户名,密码

NSString * soapBody = [NSString stringWithFormat @"<soap:Header>" 
"<AuthenticationData xmlns=\"http://www.harikishan.com/\"> 
    "<CompanyId>%@</CompanyId>" 
    "<UserName>%@</UserName>" 
    "<Password>%@</Password>" 
    "</AuthenticationData>" 
    "</soap:Header>", companyID, userName, password]; 

然后添加NSMutableURLRequest * request

+1

如果你有一个独立的类来制作soaprequesthandler&soapresponsehandler,那会更好。 – 2013-04-09 08:39:24

+0

@LithithB你是对的,但这不是问题。 – HernandoZ 2013-04-09 08:43:49

+0

您需要对这些值进行XML编码。 – 2013-04-09 11:00:12

1

一般而言,您将需要构造XML有效载荷,ma king确保对插入的任何字符串进行XML编码,并使用NSURLRequest将其发布到服务器。然后您可以收到回复并处理相应的问题