1

My application is calling wcf service.but it un suscess. I would like to implement an authentication method which sends username and password to server and a server sends response, but it not work. Here is logdebug :

org.xmlpull.v1.XmlPullParserException: unexpected type (position:END_DOCUMENT null@1:0 in java.io.InputStreamReader@40531b28) 

Code check authenticate:

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");
          }
   }

Here mycode client :

 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();

}

I don't know bescaus this. i try how to set soap Header using ksoap2 - android but it's not work for me. please help me . Many thanks.

Community
  • 1
  • 1
  • This is a common problem with WCF webservices.See the link below and you'll get that you are not alone who is facing this problem.... http://code.google.com/p/ksoap2-android/issues/detail?id=26 – himanshu Feb 02 '12 at 12:47

0 Answers0