开发者

Consuming WCF service in objective C

开发者 https://www.devze.com 2023-04-06 18:26 出处:网络
I m new to iPhone programming. What I want to do authenticate a user in iPhone using webservice. For instance

I m new to iPhone programming. What I want to do authenticate a user in iPhone using webservice. For instance

I Have a WCF webservice that I want to c开发者_如何学JAVAonsume in my objective C code.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Runtime.Serialization;
using MobileKpi.Business;

namespace MobileKpi.Services
{

[ServiceContract]
public interface IUploadData
{
[OperationContract]
[WebInvoke(UriTemplate = "UploadUserSessionData/", Method = "POST")]
string UploadUserSessionData(SessionXML pstrXML);

}

[DataContract(Namespace = "", Name = "UserLogin")]
public class UserLogin
{
    string user = "";
    string pass = "";

    [DataMember(Name = "userName")]
    public string userName
    {
        get { return user; }
        set { user = value; }
    }

    [DataMember(Name = "password")]
    public string password
    {
        get { return pass; }
        set { pass = value; }
    }
}
} 

I want to access its two data members user and password . How can I do it in Objective C.

Any solutions Or Sample Code.


One place you could start is reviewing the code in the answer of this SO question. It shows how to send JSON but you could tweak it to work with XML instead. In your code, you don't show how you expect UserLogin to be sent to the service. You could add it as a parameter as follows:

[ServiceContract]
public interface IUploadData
{
    [OperationContract]
    [WebInvoke(UriTemplate = "UploadUserSessionData/", Method = "POST")]
    string UploadUserSessionData(SessionXML pstrXML, UserLogin credentials);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号