これを実現するには、独自の WsdlExportExtension を作成する必要があります。
サンプルは次のとおりです。
public class WsdlExportBehavior : Attribute, IContractBehavior, IWsdlExportExtension
{
public void ExportContract(WsdlExporter exporter, WsdlContractConversionContext context)
{ }
public void ExportEndpoint(WsdlExporter exporter, WsdlEndpointConversionContext context)
{
var schemaSet = exporter.GeneratedXmlSchemas;
foreach (var value in schemaSet.GlobalElements.Values)
{
MakeNotNillable(value);
}
foreach (var value in schemaSet.GlobalTypes.Values)
{
var complexType = value as XmlSchemaComplexType;
if (complexType != null && complexType.ContentTypeParticle is XmlSchemaSequence)
{
var sequence = complexType.ContentTypeParticle as XmlSchemaSequence;
foreach (var item in sequence.Items)
{
MakeNotNillable(item);
}
}
}
}
private static void MakeNotNillable(object item)
{
var element = item as XmlSchemaElement;
if (element != null)
{
element.IsNillable = false;
}
}
public void AddBindingParameters(ContractDescription description, ServiceEndpoint endpoint, BindingParameterCollection parameters)
{ }
public void ApplyClientBehavior(ContractDescription description, ServiceEndpoint endpoint, ClientRuntime client)
{ }
public void ApplyDispatchBehavior(ContractDescription description, ServiceEndpoint endpoint, DispatchRuntime dispatch)
{ }
public void Validate(ContractDescription description, ServiceEndpoint endpoint)
{ }
}
[WsdlExportBehavior] をサービス クラスに適用します。
お役に立てれば。