簡體   English   中英

WCF REST服務不起作用

[英]WCF REST service doesnt work

我創建了簡單的WCF Web服務項目,並在其上啟用了soap and rest服務。

soap服務可以正常運行,但是我無法使用其余的服務和幫助頁面。

這是我的做法:

  1. 我的網絡服務類:

     [OperationContract] [WebInvoke(Method = "GET", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json, UriTemplate = "/InsertWithDate/personTypeName({personTypeName})/accessName({accessName})/firstName({firstName})/lastName({lastName})/nationalID({nationalID})/email({email})/userName({userName})/passwordHash({passwordHash})/genderName({genderName})/statusName({statusName})")] [Description("Description for GET /InsertWithDate")] string InsertWithDate(string personTypeName, string accessName, string firstName, string lastName, string nationalID, string email, string userName, string passwordHash, string genderName, string statusName); 
  2. 我的web.config文件:

     <?xml version="1.0"?> <configuration> <appSettings> <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /> <!-- (Log4net diagnostics) --> <add key="log4net.Internal.Debug" value="true"/> </appSettings> <system.web> <compilation debug="true" targetFramework="4.5" /> <httpRuntime targetFramework="4.5"/> </system.web> <system.serviceModel> <!-- Add Rest service --> <services> <service name="WcfWebService.TestWS" behaviorConfiguration="ServiceBehavior"> <!-- Use a bindingNamespace to eliminate tempuri.org. bindingNamespace="http://contoso.com/services" --> <endpoint address="soap" binding="basicHttpBinding" contract="WcfWebService.ITestWS"/> <endpoint address="rest" binding="webHttpBinding" behaviorConfiguration="http" contract="WcfWebService.ITestWS"/> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> </service> </services> <behaviors> <serviceBehaviors> <!-- Web service behavior (All kind of web Services hast it) --> <behavior name="ServiceBehavior"> <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/> <serviceDebug includeExceptionDetailInFaults="true"/> </behavior> </serviceBehaviors> <!-- Rest service behavier) --> <endpointBehaviors> <behavior name="http"> <webHttp/> </behavior> </endpointBehaviors> </behaviors> <protocolMapping> <add binding="basicHttpsBinding" scheme="https" /> </protocolMapping> <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> <standardEndpoints> <webHttpEndpoint> <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"/> </webHttpEndpoint> </standardEndpoints> </system.serviceModel> <system.webServer> <modules runAllManagedModulesForAllRequests="true"/> <directoryBrowse enabled="true"/> </system.webServer> </configuration> 

現在,當我嘗試這些頁面時:

  1. 本地主機:51850 / TestWS.svc / help
  2. 本地主機:51850 / TestWS.svc / InsertWithDate / help
  3. 本地主機:51850 / TestWS.svc / InsertWithDate / personTypeName(10)/ accessName(10)/ firstName(mn)/ lastName(mn)/ nationalID(12)/ email(a@asd.com)/ userName(nvcvncm)/ passwordHash (123)/性別名(男性)/狀態名(d)

出現同一頁面:“ /”應用程序中的服務器錯誤。

謝謝。

更新:沒有錯誤:僅此頁面: 在此處輸入圖片說明

不好意思,很抱歉:我完全忘記了我的REST服務的地址:休息,而且也為了啟用幫助頁面,我只是將<webHttp helpEnabled="true"/>到我的web.conf文件中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM