简体   繁体   中英

I am getting error in consuming WCF service

I have seen lot of answers in stackoverflow but they doesnt help me out. 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

<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

[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
            });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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