I am generating proxy classes to a clients java webservice wsdls and xsd files with svcutil. The first call made to each service proxy class takes a very long time. I was hoping to speed this up by generating the XmlSerializers assembly myself (based on the article How to: Improve the Startup Time of WCF Client Applications using the XmlSerializer), but when I do the first call to each service still takes the same amount of time. Here are the steps I am following:
//generate strong name key file
sn -k Blah.snk
//generate the proxy class file
svcutil blah.wsdl blah2.wsdl blah3.wsdl ... base.xsd blah.xsd ... /UseSerializerForFaults /ser:XmlSerializer /n:*,SomeNamespace /out:Blah.cs
//compile the class into an assembly signing it with the strong name key file
csc /target:library /keyfile:Blah.snk /out:Blah.dll Blah.cs
//generate the XmlSerializer code this will give us Blah.XmlSerializers.dll.cs
svcutil /t:xmlSerializer Blah.dll
//compile the xmlserializer code into its own dll using the same key to sign it and referencing the original dll
csc /target:library /keyfile:Blah.snk /out:Blah.XmlSerializers.dll Blah.XmlSerializers.dll.cs /r:Blah.dll
I then create a standard Console application that references both Blah.dll
and Blah.XmlSerializers.dll
. I will then try something like:
//BlahProxy is one of the generated service proxy classes
BlahProxy p = new BlahProxy();
//this call takes 30ish seconds
p.SomeMethod();
BlahProxy p2 = new BlahProxy();
//this call takes < 1 second
p2.SomeMethod();
//BlahProx2y is one of the generated service proxy classes
BlahProxy2 p3 = new BlahProxy2();
//this call takes 30ish seconds
p3.SomeMethod();
BlahProxy2 p4 = new BlahProxy2();
//this call takes < 1 second
p4.SomeMethod();
I know that the problem is not server side because I don't see the request made in Fiddler until around 29 seconds. Subsequent calls to each service take < 1 second, so thats why I was hoping the main slow down was the .net runtime generating the xmlserializer code itself, compiling it and loading the assembly. I figured this would be the reason the first call to each service is slow and the rest are fast. Unfortunatley, me generating the code myself is not speeding anything up. Does anyone see what I am doing wrong?