C# 我在使用WCF服务时出错

C# 我在使用WCF服务时出错,c#,jquery,wcf,C#,Jquery,Wcf,我在stackoverflow中看到了很多答案,但它们对我没有帮助。我有wcf服务 当我运行它时,它会在浏览器上显示有效的输出。当我在jquery客户端中使用它时,它不会提供任何输出。我想使用该wcf服务绘制一个图形 下面是我的配置文件 <system.serviceModel> <services> <service name="WcfService1.Service1" behaviorConfiguration="WcfService1.S

我在stackoverflow中看到了很多答案,但它们对我没有帮助。我有wcf服务 当我运行它时,它会在浏览器上显示有效的输出。当我在jquery客户端中使用它时,它不会提供任何输出。我想使用该wcf服务绘制一个图形 下面是我的配置文件

<system.serviceModel>
    <services>
      <service name="WcfService1.Service1" behaviorConfiguration="WcfService1.Service1Behavior">
        <!-- Service Endpoints -->
        <endpoint address="" binding="webHttpBinding" contract="WcfService1.IService1" behaviorConfiguration="web">
          <!-- 
              Upon deployment, the following identity element should be removed or replaced to reflect the 
              identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
              automatically.
          -->
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="WcfService1.Service1Behavior">
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="web">
          <webHttp/>
        </behavior>

      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>

只需将您的服务配置为跨域:

Hai web developer我对wcf有点陌生。你能帮我修改web.config文件中的哪些地方吗。如果我复制并粘贴该站点中的代码,它将显示错误..Sry Yar..我甚至不知道silverlight..请在web.config文件中说明修改内容。感谢您的快速回复…此示例可能会帮助您:以下是一个解决方案:尝试在服务器上调用您的web服务。1) 对服务器的ajax请求2)从服务器调用wcf 3)向客户端返回结果
[ServiceContract]
    public interface IService1
    {

        [OperationContract]
        [WebInvoke(Method="GET",ResponseFormat=WebMessageFormat.Json,BodyStyle=WebMessageBodyStyle.Wrapped,UriTemplate="empdetials")]
        List<employee> empdetials();

    }
$(document).ready(function () {
            var sourcee = {};

            $.ajax({
                cache: false,
                async: true,
                type: "GET",
                url: "http://localhost:1331/Service1.svc/empdetials",

                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    alert(data.d);
                    sourcee = $.parseJSON(data.d);
                    alert(sourcee);
                },
                error: fnerrorcallback
            });