1
我的應用程序正在調用wcf服務,但它沒有任何問題。我想實現一種認證方法,它將用戶名和密碼發送給服務器,服務器發送響應,但不起作用。 這裏是logdebug:無法在android中驗證wcf服務
org.xmlpull.v1.XmlPullParserException: unexpected type (position:END_DOCUMENT [email protected]:0 in [email protected])
碼校驗身份驗證:
public override void Validate(string userName, string password)
{
if (userName == null || password == null)
{
throw new ArgumentNullException();
}
Account account = new Account();
bool success = account.Login(userName, password);
LogSystem log = new LogSystem();
log.LogToFile(userName + ":" + password);
bool success = (userName == "admin" && password == "admin");
if (!success)
{
throw new FaultException("wrong user or pass");
}
}
這裏mycode的客戶:
try {
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER10);
envelope.dotNet = true;
Element userName = new Element().createElement(NAMESPACE, "userName");
userName.addChild(Node.TEXT, "admin");
userName.setNamespace(NAMESPACE);
Element password = new Element().createElement(NAMESPACE, "password");
password.addChild(Node.TEXT, "admin");
password.setNamespace(NAMESPACE);
envelope.headerOut = new Element[2];
envelope.headerOut[0] = userName;
envelope.headerOut[1] = password;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.debug = true;
androidHttpTransport.call(SOAP_ACTION, envelope);
String xmlString = envelope.getResponse().toString();
Log.e("NewWS", " " + xmlString);
tv1.setText(androidHttpTransport.requestDump);
} catch (Exception E) {
E.printStackTrace();
}
我不知道這bescaus。 我嘗試how to set soap Header using ksoap2 - android但它對我來說不起作用。 請幫助我。 非常感謝。