Ask a questionAsk a question
 

AnswerPrecompile a Web Service?

  • Thursday, November 05, 2009 5:26 PMAndrewR73 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I wrote a web service and deployed it to our server.  The web service itself works great, but I have noticed that when you first call it there is a bit of a delay, but from that point on it is practically instantaneous.  I believe this is because it needed to be compiled that first time and placed into active memory, yes? As long as the web service is called on a fairly regular basis thereafter it responds basically instantly, but... if a long time passes (say an hour or more) before it is called again, that first call has a delay again, and from there on it is instant once more.

    How do you precompile or force the web service to stay active at all times?  The 'end user' here may not call the web service all the time, but I need it to be as fast as possible whenever they do.

    Help?

    -- Andrew


Answers

  • Thursday, November 05, 2009 8:19 PMJohn SaundersMVP, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Unless you created the web service in a "Web Site Project", there is no compilation involved at runtime.

    All that's left is the normal Just-in-Time "compilation" of the .NET Intermediate Language code into machine language. You can remove that delay by creating a simple client program to call your service when the system starts. This could be a console application, or perhaps a Windows Service.


    John Saunders
    WCF is Web Services. They are not two separate things.
    Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
    Use File->New Project to create Web Service Projects

All Replies

  • Thursday, November 05, 2009 8:19 PMJohn SaundersMVP, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Unless you created the web service in a "Web Site Project", there is no compilation involved at runtime.

    All that's left is the normal Just-in-Time "compilation" of the .NET Intermediate Language code into machine language. You can remove that delay by creating a simple client program to call your service when the system starts. This could be a console application, or perhaps a Windows Service.


    John Saunders
    WCF is Web Services. They are not two separate things.
    Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
    Use File->New Project to create Web Service Projects