<?xml version="1.0" encoding="utf-8"?> <configuration> <system.web> <compilation debug="true" /> </system.web> <!-- When deploying the service library project, the content of the config file must be added to the host's app.config file. System.Configuration does not support config files for libraries. --> <system.serviceModel> <services>
<service name="AppWcfServicesLibrary.AnnounceBLLService" behaviorConfiguration="announceBehavior"> <host> <baseAddresses> <add baseAddress="http://192.168.0.128:8732/AnnounceBLLService/" /> </baseAddresses> </host> <endpoint address="AppWcfServicesLibrary/MockCategoryService/" binding="wsHttpBinding" contract="AppWcfServicesLibrary.ICategoryService" bindingConfiguration="wsHttpBindingConfiguration"> </endpoint> <endpoint address="AppWcfServicesLibrary/MockAnnounceService/" binding="wsHttpBinding" contract="AppWcfServicesLibrary.IAnnounceService" bindingConfiguration="wsHttpBindingConfiguration"> </endpoint> <endpoint address="category" binding="mexHttpBinding" contract="IMetadataExchange" /> </service> </services> <bindings> <wsHttpBinding> <binding name="wsHttpBindingConfiguration"> <security mode="None"> </security> </binding> </wsHttpBinding> </bindings> <behaviors> <serviceBehaviors> <behavior name="metadataBehavior"> <serviceMetadata httpGetEnabled="True" httpGetUrl="http://192.168.0.128:8732/northwindservice/metadata"/> <serviceDebug includeExceptionDetailInFaults="False" /> <dataContractSerializer maxItemsInObjectGraph="6553600"/> </behavior> <behavior name="announceBehavior"> <serviceMetadata httpGetEnabled="True" httpGetUrl="http://192.168.0.128:8732/northwindservice/announce"/> <serviceDebug includeExceptionDetailInFaults="False" /> <dataContractSerializer maxItemsInObjectGraph="6553600"/> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel> <connectionStrings> <add name="NorthwindEntities" connectionString="metadata=res://*/Northwind.csdl|res://*/Northwind.ssdl|res://*/Northwind.msl;provider=System.Data.SqlClient;provider connection string="data source=.;initial catalog=Northwind;integrated security=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" /> </connectionStrings> </configuration>
运行的时候出现Cannot obtain Metadata from http://192.168.0.128:8732/AnnounceBLLService/category If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address
的错误,删掉一个endpoint节点就正确,不知道为什么。。。。。
你的地址address一样,无法区别吧。
是基地址一样呢还是endpoint相对地址一样?endPoint的 两个地址不一样啊address="AppWcfServicesLibrary/MockCategoryService/"
address="AppWcfServicesLibrary/MockAnnounceService/
其实异常信息已经说得很明白了,由于两个终结点的address相同,所以当你访问的时候,服务器不知道你访问哪一人终结点,所以说了这句话,which you have access
分明不一样啊
address="AppWcfServicesLibrary/MockCategoryService/"
address="AppWcfServicesLibrary/MockAnnounceService/
两个service endpoint 但是只有一个 metadata publish <endpoint address="category" binding="mexHttpBinding" contract="IMetadataExchange" />
应该是这里错了吧 再加一个
减少一个behavior 试试