我已经创建了一个带有端点的WCF服务,该端点托管在IIS中,并带有一个.svc文件。当我到达端点时,我得到:

看来终点到了。
我已经签订了一份服务合同
[ServiceContract]
public interface ImyService
{
[OperationContract]
String GetSearchResults();
}并创建了一个类
[AspNetCompatibilityRequirements(RequirementsMode=AspNetCompatibilityRequirementsMode.Allowed)]
public class myService : ImyService
{
public String GetSearchResults()
{
return "Hello World";
}
}如何在浏览器中调用GetSearchResults方法?
编辑
其约束力是:
<bindings>
<basicHttpBinding>
<binding name="customBasicHttpBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm"/>
</security>
</binding>
</basicHttpBinding>
</bindings>发布于 2011-12-09 14:19:27
不能在浏览器中测试WCF服务的结果。您可以使用WCF客户端来测试它。在IDE中,只需打开.svc或.svc.cs文件,然后单击F5,这将启动。
注意:您的项目类型是WCF服务应用程序项目
还可以在web.config中设置下面的内容,以启用元数据交换。
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>发布于 2011-12-09 14:18:20
为什么不直接启用服务元数据生成呢?一旦有了它,您就可以在Visual中右键单击您的服务,并选择“Browse.”。VS会将浏览器打开到正确的URL,然后单击要执行的方法的名称。然后,您将看到正确的URL来调用您的方法,前提是启用了HTTP (因此您没有使用SOAP)。
否则,您将不得不使用WCF测试环境,如WCF:http://www.wcfstorm.com/wcf/home.aspx
发布于 2011-12-09 14:03:12
只有在使用webHttpBinding的情况下,才能从浏览器中执行此操作。您可以做的是使用WcfTestClient工具--它位于这里:"C:\Program (x86)\Microsoft 10.0\Common7\IDE\WcfTestClient.exe“
此外,元数据是禁用的,因此为了使用WcfTestClient,需要在webservice app.config中将httpGetEnabled设置为true。
https://stackoverflow.com/questions/8446573
复制相似问题