如何从浏览器调用WCF服务OperationContract?

我创建了一个WCF 4 Web服务并将其托管在我的IIS 7 ,我提供了以下Service URL:WCF项目的发布Web部分:

http://localhost:8084/service1.svc

然后我将我发布的web site绑定在端口: 4567并在IIS键入: http

 To checked it i clicked on `web site` at `IIS` and click on the browse. It open a following page at my browser: 

在此处输入图像描述

这意味着Web服务已成功托管在IIS 。 现在我想调用我的实例方法并在浏览器中返回输出。 让我粘贴Iservice.csservice.svc.cs的示例代码

 #Iservice.cs: namespace some.decryption { [ServiceContract] public interface Iservice { [OperationContract, WebInvoke(Method = "GET", UriTemplate = "/getdata", ResponseFormat = WebMessageFormat.Json)] string getdata(); }} 

而我的service.svc.cs

 public bool getdata() { return somenamespace.getfetcheddll(); } 

serviceDll.cs

  namespace somenamespace{ internal static class UnsafeNativeMethods { _dllLocation = "some.dll"; [DllImport(_dllLocation, CallingConvention = CallingConvention.Cdecl)] public static extern bool OnDecryption(); } public static string getfetcheddll() { return UnsafeNativeMethods.OnDecryption(); }} 

我应该如何从浏览器调用getdata()方法?

我把some.dll放在同一个项目文件夹中。 我应该在哪里做?

编辑:

我忘了粘贴我的web.config

                

要做到这一点,我按照这个博客: 创建的演练

默认情况下 – HTTP被转换为wsHttpBinding ,这是一个SOAP服务,所以你不能只是从浏览器调用它。 帮助页面上的?wsdl后缀似乎也指向了这个方向。

要测试SOAP服务,您需要一个支持SOAP的工具,如Microsoft WCF测试客户端或SoapUI 。

尝试使用WCF测试客户端 – 您是否可以使用该工具通过帮助页面上显示的URL连接到您的服务? 你看到你的服务了吗?