1
私のアプリケーションはwcf service.butを呼び出しています。私は、サーバーにユーザー名とパスワードを送信し、サーバーが応答を送信する認証方法を実装したいと思いますが、機能しません。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クライアント:私はこのbescaus知らない
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();
}
ここ はlogdebugです。 私はhow to set soap Header using ksoap2 - androidを試していますが、それは私の仕事ではありません。 私を助けてください。 多くのありがとうございます。