我创建了简单的WCF Web服务项目,并在其上启用了soap和rest服务。
soap服务工作正常,但我无法使用其余服务和帮助页面。
我是这样做的:
我的网络服务类:
[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);
我的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>
现在,当我尝试这些页面时:
出现相同的页面:&#39; /&#39;中的服务器错误应用
谢谢。更新: 没有错误:只是这个页面:
答案 0 :(得分:0)
抱歉,我的错:我完全忘记了我的REST服务地址:休息
并且为了启用帮助页面,我只需将<webHttp helpEnabled="true"/>
添加到我的web.conf
文件中。