简体   繁体   English

使用WCF服务时出现错误

[英]I am getting error in consuming WCF service

I have seen lot of answers in stackoverflow but they doesnt help me out. 我在stackoverflow中看到了很多答案,但它们并没有帮助我。 I am having a wcf service which when I am running it is showing valid output on the browser.When I am consuming that in a jquery client It is not giving any output.I want to use that wcf service to plot a graph the following is my config file 我有一个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>

the follwoing is my cs code 以下是我的cs代码

[ServiceContract]
    public interface IService1
    {

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

    }

the following is my client side code 以下是我的客户端代码

$(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
            });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM