Reputation: 2013
I am using svcutil.exe to generate a service endpoint based on a contract from an external source.
It seems to work as intended, but the service is not able to expose an endpoint to others.
Specifically, when I try to GET the WSDL for the service, an exception is thrown with the following error:
System.InvalidOperationException: An exception was thrown in a call to a WSDL export extension: System.ServiceModel.Description.XmlSerializerOperationBehavior contract: http://tempuri.org/xml/wsdl/soap11/DistributionService/1/port:DistributionReceiverWebServicePort ----> System.Xml.Schema.XmlSchemaException: The complexType 'http://tempuri.org/xml/wsdl/soap11/DistributionService/1/types:FejlType' has already been declared.
But - the type FejlType
type is only declared once and is a very simple class:
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "http://tempuri.org/xml/wsdl/soap11/DistributionService/1/types")]
[System.Runtime.Serialization.DataContractAttribute(Name = "FejlType", Namespace = "http://tempuri.org/xml/wsdl/soap11/DistributionService/1/types")]
public class FejlType : object, System.Runtime.Serialization.IExtensibleDataObject
{
private System.Runtime.Serialization.ExtensionDataObject extensionDataField;
private string FejlKodeField;
private string FejlTekstField;
public System.Runtime.Serialization.ExtensionDataObject ExtensionData
{
get {return this.extensionDataField;}
set {this.extensionDataField = value;}
}
[System.Runtime.Serialization.DataMemberAttribute(IsRequired = true, EmitDefaultValue = false)]
public string FejlKode
{
get {return this.FejlKodeField;}
set {this.FejlKodeField = value;}
}
[System.Runtime.Serialization.DataMemberAttribute(IsRequired = true, EmitDefaultValue = false)]
public string FejlTekst
{
get {return this.FejlTekstField;}
set {this.FejlTekstField = value;}
}
}
I am totally in the dark here - why does WCF complain about this when exporting the WSDL?
Upvotes: 4
Views: 2943
Reputation: 2013
I found the cause of the problem.
FYI: the WSDL originates from KOMBIT (a Danish Government IT-thingy) and the WSDL is a part of their data hub (Serviceplatformen)
I discovered that the service classes generated by svcutil.exe had the type FejlType
implemented twice - both as partial classes, btw. One of them had a specific .net namespace prefix and the other did not have its own prefix. What was causing the problem was an XmlTypeAttribute
on the types - each of them exposing the same xml namespace. So even though the service classes did compile, they exposed the same xml type specification - causing the exception I reported here.
Upvotes: 4