繁体   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