简体   繁体   中英

Error when accessing access the WSDL of my WCF services: “The … operation references a message element … that has already been exported from the …”

I experience a weird behavior when accessing my web services into a web browser and it leads to an exception while generating.

Here is my scenario:

  1. Access web page: http://localhost:10100/WCFService1.svc?wsdl

  2. Access web page: http://localhost:10100/WCFService2.svc?wsdl

The problem is that the output of WCFService2.svc WSDL contains all the definition of WCFService1 merged with WCFService2.

Furthermore, when I access another WSDL which contains a method having the same name of previously generated WSDL, I get this exception (surely because my WSDL are being merged together).

I also notice the name of the contract is kind of weird having the ":" before the service name: http://MyCompany.ca/:IWCFService3

Someone have a clue what is going on with the "WSDL export extension"?


An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
System.InvalidOperationException: An exception was thrown in a call to a WSDL export extension:
System.ServiceModel.Description.DataContractSerializerOperationBehavior contract: http://MyCompany.ca/:IWCFService3
----> System.InvalidOperationException: The MyCompany.IWCFService3.Import operation references a message element [http://MyCompany.ca/:Import] that has already been exported from the MyCompany.IWCFService2.Import operation. You can change the name of one of the operations by changing the method name or using the Name property of OperationContractAttribute. Alternatively, you can control the element name in greater detail using the MessageContract programming model. at System.ServiceModel.Description.MessageContractExporter.AddElementToSchema(XmlSchemaElement element, String elementNs, XmlSchemaSet schemaSet) at System.ServiceModel.Description.MessageContractExporter.ExportWrappedPart(Message message, String elementName, String elementNs, XmlSchemaSet schemaSet, Boolean skipSchemaExport) at System.ServiceModel.Description.DataContractSerializerMessageContractExporter.ExportBody(Int32 messageIndex, Object state) at System.ServiceModel.Description.MessageContractExporter.ExportMessage(Int32 messageIndex, Object state) at System.ServiceModel.Description.MessageContractExporter.ExportMessageContract() at System.ServiceModel.Description.DataContractSerializerOperationBehavior.System.ServiceModel.Description.IWsdlExportExtension.ExportContract(WsdlExporter exporter, WsdlContractConversionContext contractContext) at System.ServiceModel.Description.WsdlExporter.CallExtension(WsdlContractConversionContext contractContext, IWsdlExportExtension extension)

I found my problem: We have a huge set of Web Services and we were having a single instance of System.ServiceModel.Description.ServiceMetadataBehavior that we were sharing among all the services. Making a new instance of ServiceMetadataBehavior for each service fixed the issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM