2012-05-16 70 views
0

我用我application.In SOAP服務,我收到錯誤消息KSOAP故障異常

SoapFault - faultcode: 'soap:Client' faultstring: 'System.Web.Services.Protocols.SoapException: Server was unable to read request. ---> System.InvalidOperationException: There is an error in XML document (1, 301). ---> System.InvalidOperationException: The specified type was not recognized: name='authentication', 

我的SOAP請求結構是:

<authentication> 
    <LoginID>string</LoginID> 
    <Password>string</Password> 
    </authentication> 
    <Id>int</Id> 
    <Str>string</Str> 

我的代碼是:

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 

       PropertyInfo usrid =new PropertyInfo(); 
      usrid.setName("LoginID"); 
      usrid.setValue(userid); 
      usrid.setType(String.class); 
      request.addProperty(usrid);   

//   
      PropertyInfo pass =new PropertyInfo(); 
      pass.setName("Password"); 
      pass.setValue(password); 
      pass.setType(String.class); 
      request.addProperty(pass); 

       PropertyInfo rote =new PropertyInfo(); 
      rote.setName("Id"); 
      rote.setValue(4114616); 
      rote.setType(int.class); 
      request.addProperty(rote); 
//   
      PropertyInfo dte =new PropertyInfo(); 
      dte.setName("Str"); 
      dte.setValue(date); 
      dte.setType(String.class); 
      request.addProperty(dte); 



androidHttpTransport.call(SOAP_ACTION,envelope);    
//    SoapPrimitive response = (SoapPrimitive)envelope.getResponse(); 
       System.out.println("subbu"); 
       Object response=(Object)envelope.getResponse();---->I think i am getting error here. 

任何人都可以請幫助我做錯了什麼。

回答

1

請查看以下鏈接:

authentication是一個複雜的對象,但你已經連續添加的所有屬性。嘗試是這樣的:

SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); 

SoapObject authenticate = new SoapObject(NAMESPACE, "authenticate"); 
authenticate.addProperty("LoginID", "login"); 
authenticate.addProperty("Password", "password"); 

request.addSoapObject(authenticate); 
request.addProperty("Id", "123"); 
request.addProperty("Str", "string"); 
+0

您好感謝UR reply..but我不能得到答案..所有的 – subburaj

+0

首先,你沒有發佈您的代碼,所以很難說「_what你做wrong_ 」。 – StenaviN

+0

嗨StenaviN.I發佈了我的代碼。 – subburaj