我的应用程序正在调用wcf service.but它un suscess。我想实现一个身份验证方法,它将用户名和密码发送到服务器,服务器发送响应,但它不起作用。 这是logdebug:
org.xmlpull.v1.XmlPullParserException: unexpected type (position:END_DOCUMENT null@1:0 in java.io.InputStreamReader@40531b28)
代码检查身份验证:
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();
}
我不知道这是什么意思。 我试试how to set soap Header using ksoap2 - android,但这对我不起作用。 请帮我 。 非常感谢。