我想設置一個Web服務,返回JSON對象獲得元數據和我下面這個tutorial但是當我去嘗試運行它,我得到這個錯誤不能與WCF
Error: Cannot obtain Metadata from
http://localhost:10995/Service1.svc
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. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error URI:http://localhost:10995/Service1.svc
Metadata contains a reference that cannot be resolved: 'localhost:10995/Service1.svc'. The remote server returned an unexpected response: (405) Method Not Allowed. The remote server returned an error: (405) Method Not Allowed.HTTP GET Error URI:http://localhost:10995/Service1.svc
There was an error downloadinghttp://localhost:10995/Service1.svc
. The request failed with HTTP status 404: Not Found.
於是,我找了這意味着什麼,並在這些鏈接來嘗試修復它
WCF - Error: Cannot obtain Metadata
Error: Cannot obtain Metadata from WCF service
WCF Test Client cannot add service, cannot obtain metadata
但他們沒有固定的問題。這是我第一次嘗試做任何網絡服務的東西,我今天從字面上開始研究,所以顯然我是所有這些新手。
這個錯誤是什麼意思,我怎樣能解決這個問題,所以我可以試一下嗎?
<system.serviceModel>
<services>
<service name="WcfService4.Service1" behaviorConfiguration="WcfService4.Service1Behavior">
<!-- Service Endpoints -->
<endpoint address="../Service1.svc"
binding="webHttpBinding"
contract="WcfService4.IService1"
behaviorConfiguration="webBehaviour" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WcfService4.Service1Behavior">
<!-- To avoid disclosing metadata information, set the value below to false before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="webBehaviour">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
正確檢查您的端點地址,行爲配置和合同名稱。 – Sajeetharan