当我 运行 WCF 服务中的简单方法时,“/”应用程序中的服务器错误
Server Error in '/' Application when I am running the simple method in WCF Service
[当我在 u-r-l 中添加方法测试时,它说服务器应用程序出错]
[这是我的 W.C.F 服务中的内容,我正在尝试查看方法测试][3]
public string test()
{
// Add your operation implementation here
return "test...";
}
下面是错误
https://i.stack.imgur.com/EdFt9.png
如果你想在浏览器中直接访问你的WCF操作,可以参考下面的配置。
服务合同。
public interface IService1
{
[OperationContract]
[WebGet]
string GetData(int value);
}
Service.svc
public string GetData(int value)
{
return DateTime.Now.ToLongTimeString();
}
Web 配置,只需替换 System.servicemodel 部分。
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior>
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<protocolMapping>
<add binding="webHttpBinding" scheme="http" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
结果。
有关如何创建基本 WCF Web HTTP 服务的更多详细信息。
https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/how-to-create-a-basic-wcf-web-http-service
如果有什么我可以帮忙的,请随时告诉我。
[当我在 u-r-l 中添加方法测试时,它说服务器应用程序出错] [这是我的 W.C.F 服务中的内容,我正在尝试查看方法测试][3]
public string test()
{
// Add your operation implementation here
return "test...";
}
下面是错误 https://i.stack.imgur.com/EdFt9.png
如果你想在浏览器中直接访问你的WCF操作,可以参考下面的配置。
服务合同。
public interface IService1
{
[OperationContract]
[WebGet]
string GetData(int value);
}
Service.svc
public string GetData(int value)
{
return DateTime.Now.ToLongTimeString();
}
Web 配置,只需替换 System.servicemodel 部分。
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior>
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<protocolMapping>
<add binding="webHttpBinding" scheme="http" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
结果。
有关如何创建基本 WCF Web HTTP 服务的更多详细信息。
https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/how-to-create-a-basic-wcf-web-http-service
如果有什么我可以帮忙的,请随时告诉我。