1

I used WCF to call a Java based web service and constantly get 1.4 second or 1.5 second response time. I used exactly same SOAP request in SoapUI to call the same web service and constantly get 0.9 second to 1 second response time.

Both requests are initiated from my local computer, both requets hit same target.

It is very hard for me to believe it will take 0.5 second to serialize and deserialize, but other than this what else can impact the performance?

Update 1 - included sample code

        Stopwatch sw = new Stopwatch();

        //Trust all certificates, non-production uses self-signed certificate
        System.Net.ServicePointManager.ServerCertificateValidationCallback = ((sender, certificate, chain, sslPolicyErrors) => true);

        MyServiceClient.MyService.Spml2ServicePortTypeClient client = new MyServiceClient.MyService.Spml2ServicePortTypeClient();

        client.ClientCredentials.UserName.UserName = "username";
        client.ClientCredentials.UserName.Password = "password";

        for (int i = 0; i < 5; i++)
        {
            MyServiceClient.MyService.SuggestUserIDRequestType webRequest = new MyServiceClient.MyService.SuggestUserIDRequestType();
            webRequest.requestID = "MyId";
            webRequest.givenName = "Hardy";
            webRequest.sn = "Wang";
            webRequest.uid = "some value";

            sw.Start();
            MyServiceClient.MyService.SuggestUserIDResponseType response = client.suggestUserID(webRequest);
            sw.Stop();

            Console.WriteLine("Elapsed time {0} ms.", sw.ElapsedMilliseconds);
            sw.Reset();

        }
4

0 回答 0