2010-08-23 59 views
1

嘿,這是我的Web.config文件。除Service1/help之外,一切適用於我的服務。沒有幫助WCF休息模板40

<system.web> 
    <compilation debug="true" targetFramework="4.0" /> 
    <customErrors mode="Off"/> 
    </system.web> 

    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"> 
     <remove name="UrlRoutingModule"/> 
     <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> 
    </modules> 
    <handlers> 
     <add 
     name="UrlRoutingHandler" 
     preCondition="integratedMode" 
     verb="*" path="UrlRouting.axd" 
     type="System.Web.HttpForbiddenHandler, System.Web, &#xD;&#xA;   Version=2.0.0.0, Culture=neutral, &#xD;&#xA;   PublicKeyToken=b03f5f7f11d50a3a" 
     /> 
    </handlers> 
    </system.webServer> 
    <system.serviceModel> 

    <bindings> 
     <webHttpBinding> 
     <binding name="SSLBinding"> 
      <security mode="Transport"> 
      <transport clientCredentialType="Certificate" proxyCredentialType="None" /> 
      </security> 
     </binding> 
     </webHttpBinding> 
    </bindings> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="sBehavior"> 
      <routing routeOnHeadersOnly="true" /> 
      <serviceMetadata httpsGetEnabled="true" httpsGetBinding="webHttpBinding" httpsGetBindingConfiguration="" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 



    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/> 

    <standardEndpoints> 
     <webHttpEndpoint> 
     <standardEndpoint name="Default" helpEnabled="true" automaticFormatSelectionEnabled="true"> 
      <security mode="Transport"> 
      <transport clientCredentialType="Certificate"/> 
      </security>   
     </standardEndpoint> 
     </webHttpEndpoint> 
    </standardEndpoints>  

    </system.serviceModel> 

</configuration> 

服務:

namespace UserWebServices 
{ 
    // Start the service and browse to http://<machine_name>:<port>/Service1/help to view the service's generated help page 
    // NOTE: By default, a new instance of the service is created for each call; change the InstanceContextMode to Single if you want 
    // a single instance of the service to process all calls. 
    [ServiceContract] 
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] 
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)] 
    // NOTE: If the service is renamed, remember to update the global.asax.cs file 
    public class Service1 
    { 
     // TODO: Implement the collection resource that will contain the SampleItem instances 

     [WebGet(UriTemplate = "")] 
     public List<SampleItem> GetCollection() 
     { 
      // TODO: Replace the current implementation to return a collection of SampleItem instances 
      return new List<SampleItem>() { new SampleItem() { Id = 1, StringValue = "Kader" }, 
              new SampleItem() { Id = 2, StringValue = "Weber" }}; 
     } 

     [WebGet(UriTemplate = "{id}")] 
     public SampleItem Get(string id) 
     { 
      int idConverted = Convert.ToInt32(id); 

      return new SampleItem() { Id = idConverted, StringValue = "SingleItem" };   
     } 

     [WebInvoke(UriTemplate = "", Method = "POST")]   
     public SampleItem Create(SampleItem instance) 
     { 
      if (instance == null) 
       throw new NoNullAllowedException(); 

      return instance; 
     }   

     [WebInvoke(UriTemplate = "{id}", Method = "PUT")] 
     public SampleItem Update(string id, SampleItem instance) 
     { 
      int idConverted = Convert.ToInt32(id); 

      return new SampleItem() { Id = idConverted, StringValue = "Putted" };   
     } 

     [WebInvoke(UriTemplate = "{id}", Method = "DELETE")] 
     public void Delete(string id) 
     { 
      // TODO: Remove the instance of SampleItem with the given id from the collection 
      throw new NotImplementedException(); 
     } 
    } 
} 
+0

當你請求'Service1 \ help'時會發生什麼? – 2010-08-24 00:57:45

+0

HTTP://本地主機:35810 /服務1 /幫助產量: 請求錯誤 服務器遇到錯誤處理請求。查看服務器日誌獲取更多詳細信 – 2010-08-24 17:19:43

回答