Our wsdl is very large, and it causes our SoapHttpClientProtocol
to take a very long time to initialize. As a solution, it looks like a previous developer used something similar to this solution to create a dll of the pre-generated XML serialization code.
However when using the wsdl we get exception an exception when trying to use inherited types.
For example, here is an extremely simplified version of my web service and base class :
namespace MW
{
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Name="MyWebServicePortBinding", Namespace="myNamespace")]
[System.Xml.Serialization.XmlSerializerAssemblyAttribute(AssemblyName = "MyWebService.XmlSerializers")]
public partial class MyWebService: System.Web.Services.Protocols.SoapHttpClientProtocol
{
...
}
// XmlInclude attribute removed via script
// [System.Xml.Serialization.XmlIncludeAttribute(typeof(MyChildClass))]
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="myNamespace")]
public abstract partial class MyBaseClass
{
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="myNamespace")]
public partial class MyChildClass : MyBaseClass
{
}
}
Results in an exception of this when trying to call a method that accepts a MyBaseClass
as a parameter
There is an error in XML document
The specified type was not recognized: name='MyChildClass', namespace='myNamespace'
The solution of course is to keep the [System.Xml.Serialization.XmlIncludeAttribute(typeof(MyChildClass))]
attributes in our class instead of removing them, but over time the number of these has grown to the point that it is again impacting the initialization time of our web service object, and I am wondering if there is an alternate solution.
I'm no expert at how msbuild or the compiler works, and haven't been able to find anything similar so far with Google Searches. I think if this were a common issue, it would be easy to find a solution. So now I am wondering if perhaps the previous developer that wrote our build scripts missed something.
Our build scripts run this set of commands in this order :
- Generate the webservice from wsdl :
wsdl.exe <webService>
- Build webservice with all serializers :
msbuild BuildWebservice1.xml
- Run custom script to remove
[XmlInclude]
attributes from generated webservice cs class file - Build webservice again without serializer attributes :
msbuild BuildWebservice2.xml
The only difference between the two xml files for msbuild I think is the <GenerateSerializationAssemblies>
attribute being set to On
in the first and Off
in the second, and the second includes a reference to the first.
<Reference Include="MyWebService.XmlSerializers, Version=1.0.0.41348, Culture=neutral, PublicKeyToken=2401953c7c666e82, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Serializers\MyWebService.XmlSerializers.dll</HintPath>
</Reference>
Is there something I am missing for using a pre-generated serialization assembly with inherited types?