2013-04-09 49 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將其發佈到服務器。然後您可以收到回覆並處理相應的問題