none
Web Service slow first request

    Question

  • Why web services are slow in first request and after that works well?

    How can I improve this first request?

    Sample code:

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Web;

    using System.Web.Services;

    using System.Configuration;

    using System.Data;

    using System.Data.SqlClient;

    namespace WebService

    {

        /// <summary>

        /// Summary description for ws_Translation

        /// </summary>

        [WebService(Namespace = "http://www.contoso.com/", Name = "ws_Translation")]

        [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

        [System.ComponentModel.ToolboxItem(false)]

        // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.

        // [System.Web.Script.Services.ScriptService]

        public class ws_Translation : System.Web.Services.WebService

        {

            private string is_connStr = "";

            public ws_Translation()

            {

                is_connStr = ConfigurationManager.ConnectionStrings["DBConnectionString"].ToString();

            }

            //-------------------------------------------------------------------------------

            [WebMethod]

            public DataSet m_GetTranslation(string avs_codIdomId)

            {

            // CODE HERE

            }

            //-------------------------------------------------------------------------------

        }

    }

    Thanks & Regards,

    Rui

    Saturday, March 11, 2017 2:54 PM

All replies

  • Hi Rui,

    The delay of the first web service request could be how client handles web proxy.

    The first web call execution supposes to be much slower because transport channel need to discover proxy configuration on initialization, to transparently connect to internet.

    But we could change these binding settings to avoid use the default proxy (automatically discovered from explorer settings):

    bypassProxyOnLocal="false"
    
    useDefaultWebProxy="false"

    You might try set them like above in your app.config file and have a try.

    Hope it helps.

    Best regards,

    Fletch


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Monday, March 13, 2017 3:21 AM
  • I have the following app.config. Where I insert these binding setting?

    <?xml version="1.0" encoding="utf-8" ?>

    <configuration>

      <configSections>

        <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >

          <section name="eGrouWS.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />

        </sectionGroup>

      </configSections>

      <applicationSettings>

        <eGrouWS.Properties.Settings>

        </eGrouWS.Properties.Settings>

      </applicationSettings>

    </configuration>

    Monday, March 13, 2017 10:01 AM
  • Hi Rui,

    Please refer to the format below:

    <configuration>
    <system.net>
      <defaultProxy>
        <proxy useDefaultWebProxy="false" bypassProxyOnLocal="false" />
      </defaultProxy>
    </system.net>
    </configuration>

    Best regards,

    Fletch


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, March 14, 2017 9:34 AM
  • My application gives an error when insert these binding setting. And works well without them.

    It is suppose insert these binding setting from client side or from (web service) server side?

    Thanks & Regards

    Wednesday, March 22, 2017 3:34 PM
  • Hi Rui, 

    It should be in client side. 

    Not sure if your issue has been resolved, but here is another suggestion is ;

    Right-click project name -> Property -> Build -> Generate serialization assembly -> On  

    As you change it to "On" the serialization assembly will be generated during compile time. Then the time of loading of the dll will be dropped down. 

    Please have a try and let me know the result. 

    Best regards, 

    Fletch


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Thursday, March 30, 2017 2:21 PM
  • Hi Fletch,

    After set the option:

    Right-click project name -> Property -> Build -> Generate serialization assembly -> On

    I am getting the following message error:

    Error 216 Could not find file 'E:\User\C++Projectos\eGrou\_eGrouWS_Addins\eGrouWSOutlookAddIn\bin\Release\eGrouWSOutlookAddIn.XmlSerializers.dll'. eGrouWSOutlookAddIn

    Thanks & regards,

    Rui

    Thursday, April 27, 2017 9:05 AM