Saturday, October 5, 2013

ios authentication inside webservice which should be how to write in order to obtain a user name password

For example:
NSURL * url = [NSURL URLWithString: @ "http://www.dreamingwish.com/"];
ASIHTTPRequest * request = [ASIHTTPRequest requestWithURL: url];
[Request setUseKeychainPersistence: YES];
[Request setUsername: @ "username"];
[Request setPassword: @ "password"];

This sets the user name password
webservise Where can I get

Reply:
Do you mean where to webservice code?



Reply:
是 ah,, webservice inside the code I wrote, however, found that, account passwords do not pass in the past, do not know what's going on
Reply:
public class AuthHeader: SoapHeader
{
public string Username;
public string Password;
}




/ / /
/ / / WebService1 explanatory memorandum
/ / /

[WebService (Namespace = "http://tempuri.org/")]
[WebServiceBinding (ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem (false)]
/ / To allow the use of ASP.NET AJAX script calls from this Web service, cancel comment down.
/ / [System.Web.Script.Services.ScriptService]
public class WebService1: System.Web.Services.WebService
{
public SoapHeader s;

public AuthHeader sHeader;
public bool Result ()
{
if (sHeader! = null)
{
System.IO.File.WriteAllText ("E :/ fb / ab.txt", sHeader.Username + "|" + sHeader.Password);
if (sHeader.Username == "asdbe" && sHeader.Password == "123456")
{
return true;
}
else
{
return false;

}
}
else
{
System.IO.File.WriteAllText ("E :/ fb / ab.txt", "sdaf");
return false;
}
}


[WebMethod (Description = "submit results")]
[SoapHeader ("sHeader")]
public string FeedBackAdd (string email, string content)
{
if (Result ())
{
SqlConnection con = new SqlConnection ("sdfasdf");
con.Open ();
string sqstr = ".....";
SqlCommand com = new SqlCommand (sqstr, con);



if (com.ExecuteNonQuery ()> 0)
{
con.Close ();
return "Yes";
}
else
{
con.Close ();
return "No";
}

}
else
{

return "No";

}

}

Reply:
This is the webservice code inside, but get less than that username password
sHeader is empty
Reply:
webService code in I do not know how to write. .
IOS where you look at your bar code
POST
 NSString * soapMessage = @ "xxxxxxxxxx"; 

NSURL * url = [NSURL URLWithString: CMCC_ANTENNA_URL];
NSMutableURLRequest * theRequest = [NSMutableURLRequest requestWithURL: url];
NSString * msgLength = [NSString stringWithFormat: @ "% d", [soapMessage length]];

[TheRequest addValue: @ "text / xml; charset = utf-8" forHTTPHeaderField: @ "Content-Type"];
[TheRequest addValue: FIND_ACTION forHTTPHeaderField: @ "SOAPAction"];
[TheRequest addValue: msgLength forHTTPHeaderField: @ "Content-Length"];
[TheRequest setHTTPMethod: @ "POST"];
[TheRequest setHTTPBody: [soapMessage dataUsingEncoding: NSUTF8StringEncoding]];

NSURLConnection * theConnection = [[NSURLConnection alloc] initWithRequest: theRequest delegate: self];

if (theConnection)
{
webData = [[NSMutableData data] retain];
}
else
{
NSLog (@ "theConnection is NULL");
}

Reply:
You have no place to send the code to fill the account password A
Reply:
Uh. . . You do not know how combinations request string you?

 
NSString * str = [NSString stringWithFormat:
@ " \
\
\
\
% @ \
% @ \
\
\
", username, password];

Reply:
Now the problem is not in ios this end, the question now is how to get there in the webservice there ios userName and password sent in the past
Reply:
Put simply, is how to call with authentication webservise
Reply:
This is your SOAP-based WebService, iOS SOAP request format to be spliced ​​end job, ASIHttpRequest just Http request to the default format to send request to the server, of course you can not receive.
Two solutions:
1, iOS side stitching SOAP request format by making a request
2, the server into Restful a web service, you use. Net, then you can use this project template WCF Restful Template

No comments:

Post a Comment