2010-10-10 84 views
1

我不确定是什么原因导致了这个错误。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:我试了一下建议在该网站上,没有运气。

回答

0

我最初是将AJAX引用为参考。我删除它,并做了一个典型的WCF之一,它似乎工作。 (虽然我仍然得到SecurityException问题,详见我的另一个问题。)