我使用C#在Web應用程序內構建WCF Web服務,並且由於我需要爲某些Xml參數包含模式驗證,所以我想爲該服務設置自定義wsdl我在<wsdl:types>
節點內使用<xs:include schemaLocation="<schemafilename>.xsd"/>
。使用externalMetadataLocation設置原始WSDL不起作用
我瞭解到,這個地方做,這是
<serviceMetadata externalMetadataLocation="<wsdlfilename>.wsdl"/>
,但我無法得到它的工作。讓我感到困惑的是,即使讓服務生成自己的wsdl(即不設置屬性),它也不起作用,通過<serviceurl>/<servicename>.svc?wsdl
訪問生成的元數據,將其保存到文件中,然後將此文件設置爲externalMetadataLocation (使用..\<wsdlfilename>.wsdl
)。 WcfTestClient給了我這樣的:
Warning: No code was generated.If you were trying to generate a client, this could be
because the metadata documents did not contain any valid contracts or servicesor
because all contracts/services were discovered to exist in /reference assemblies.
Verify that you passed all the metadata documents to the tool.Warning: If you would
like to generate data contracts from schemas make sure to use the /dataContractOnly
option.
有時候它讓我更加複雜的錯誤,好像
Error: Cannot import wsdl:port
Detail: Cannot find definition for http://tempuri.org/:BasicHttpBinding_IProcessi. Service Description with namespace http://tempuri.org/ is missing.Parameter name: name
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://www.archinet.it/HRSuite/Processi/']/wsdl:service[@name='Processi']/wsdl:port[@name='BasicHttpBinding_IProcessi']
Error: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: Schema with target namespace 'http://www.archinet.it/HRSuite/Processi/' could not be found.
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://www.archinet.it/HRSuite/Processi/']/wsdl:portType[@name='IProcessi']
我不是真的那麼熟練使用XML命名空間還,所以它也可能是一些關於他們,但我都試過有和沒有命名空間,所以我在虧損
謝謝
如果您使用外部元數據,您可以從瀏覽器訪問WSDL嗎? (你必須設置'httpGetEnabled =「true」') – 2011-03-01 10:44:51
是的,它將我重定向到我的本地文件 – Piddu 2011-03-01 11:06:33