我不確定是什麼原因導致了這個錯誤。Silverlight「添加服務參考」到ASP服務錯誤
服務標記:
<%@ ServiceHost
Language="C#"
Debug="true"
Service="WebRole1.ExpenseService"
CodeBehind="ExpenseService.svc.cs"
Factory="System.ServiceModel.Activation.WebServiceHostFactory"
%>
服務代碼背後:
[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class ExpenseService
{
[OperationContract]
[WebGet(UriTemplate="expenses", ResponseFormat=WebMessageFormat.Xml)]
public List<ExpenseInfo> GetExpenses()
{
List<ExpenseInfo> result = new List<ExpenseInfo>();
// ...
return result;
}
}
如果我運行該項目,並導航到瀏覽器上的服務,該數據顯示了罰款。
如果我嘗試添加服務http://localhost:88/ExpenseService.svc/expenses
,我得到的錯誤:
The document at the url http://localhost:88/ExpenseService.svc/expenses was not recognized as a known document type.
The error message from each known type may help you fix the problem:
Report from 'XML Schema' is 'The root element of a W3C XML Schema should be and its namespace should be 'http://www.w3.org/2001/XMLSchema'.'.
Report from 'DISCO Document' is 'Discovery document at the URL http://localhost:88/ExpenseService.svc/expenses could not be found.'.
The document format is not recognized.
Report from 'WSDL Document' is 'There is an error in XML document (1, 2).'.
- was not expected.
Metadata contains a reference that cannot be resolved: 'http://localhost:88/ExpenseService.svc/expenses'.
The remote server returned an unexpected response: (405) Method Not Allowed.
The remote server returned an error: (405) Method Not Allowed.
If the service is defined in the current solution, try building the solution and adding the service reference again.
如果我嘗試將服務引用添加到http://localhost:88/ExpenseService.svc
,我得到的錯誤:
There was an error downloading 'http://localhost:88/ExpenseService.svc'. The request failed with HTTP status 404: Not Found. Metadata contains a reference that cannot be resolved: 'http://localhost:88/ExpenseService.svc'. There was no endpoint listening at http://localhost:88/ExpenseService.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. The remote server returned an error: (404) Not Found. If the service is defined in the current solution, try building the solution and adding the service reference again.
什麼時我做錯了?
更新:此頁可能是有用的:http://code.msdn.microsoft.com/wcfazure/Wiki/View.aspx?title=KnownIssues
更新2:我試了一下建議在該網站上,沒有運氣。