2011-08-03 66 views
0

如何獲取服務器日期time.Android應用程序將訪問webservice.I想知道如何獲得服務器的時間。在這裏我想傳遞。目前我做我有Android時間.....Android得到正在運行的服務器/服務器日期時間

// ksoap2 calling wcf 
public SoapPrimitive soapPrimitiveData(String tablename) throws IOException,XmlPullParserException { 
    SoapPrimitive responsesData = null; 
    SoapObject requestData = new SoapObject(NAMESPACE, METHOD_TABLEDATA); // set 

    //This place I need to get server time.Here I did as normal way 
    Date date = new Date(); 
    DateFormat formatter = new SimpleDateFormat("yyyy-MMM-dd HH:mm:ss"); 
    String strDate = formatter.format(date); 

    requestData.addProperty("strBusinessUnit", strBusinessUnit); 
    requestData.addProperty("strExecutive", strExecutive); 
    requestData.addProperty("strTableName", tablename); 
    requestData.addProperty("strDate", strDate); 
    requestData.addProperty("strTerritoryCode", strTerritoryCode); 


    SoapSerializationEnvelope envelopes = new SoapSerializationEnvelope(SoapEnvelope.VER11); // put all required data into a soap//// envelope 
    envelopes.dotNet = true; 
    envelopes.setOutputSoapObject(requestData); 
    AndroidHttpTransport httpTransport = new AndroidHttpTransport(APPURL); 
    httpTransport.debug = true; 

    try { 
     httpTransport.call(SOAP_ACTION1, envelopes); 
     responsesData = (SoapPrimitive) envelopes.getResponse(); 

    } catch (SocketException ex) { 
     ex.printStackTrace(); 
    } catch (Exception e) { 
     e.printStackTrace(); 
    } 
    return responsesData; 
} 

請幫我...

在此先感謝....

回答

0

獲取服務器的時間,在那裏你可以你應該有一個接口與服務器請求時間。

例如,getTime.php可能是:

echo gmdate(); 
+0

我的WCF服務IIS服務器 – Piraba

+0

檢查編輯上運行?這是否工作? –

+0

我必須把它從java代碼(Android)。我指出的地方.... – Piraba