views:

26

answers:

0

Environment: IIS 6.0

In my web service there is only a simple web method that return the current cultrue and DateTime format:

        [WebMethod]
        public string GetDateTimeInfo()
        {
            string culture = Thread.CurrentThread.CurrentCulture.Name;

            string dt = DateTime.Now.ToString();

            string ret = string.Format("Culture=[{0}], DateTime.ToString=[{1}]", culture, dt);
            return ret;
        }

Then I deploy the web service on my product's virtual directory

And my client is a windows application, and this is pieces of client code

TestDateTimeWebService.Service1 serviceInst = new WindowsApplicationClient.TestDateTimeWebService.Service1();

serviceInst.Url = @"http://localhost/VD/TestDateTimeService.asmx";
serviceInst.Credentials = System.Net.CredentialCache.DefaultCredentials;

// call the web method

string str = serviceInst.GetDateTimeInfo();

And I run the client app in the web serive machine (not remote run), and the value of str is Culture=[en-US], DateTime.ToString=[7/23/2010 8]

And I copy the code of web method GetDateTimeInfo and paste it in client and then call it directly from client and the result is Culture=[en-US], DateTime.ToString=[7/23/2010 08:22:52]

You can see the difference is that the format result of DateTime in web method seems to be specically formatted and only the Hour field is left (Minutes and Seconds fields has gone)


I have checked the culture settings for IIS-> Default Web Site->properties->Default web site properties-> Edit Global Configuraion-> Application Tab-> globalization settings, and it is the default value "af-ZA" The Time format for English(US) in Regional and Language options is HH:mm:ss which seems also correct

Can anybody give me some hint why the web service call return a special formatted DateTime?