2013-11-04 39 views
0

我在stackoverflow中看到了很多答案,但他们不帮我。我有一个wcf服务 ,当我运行时,它显示在浏览器上的有效输出。当我在jQuery客户端使用它没有给出任何输出。我想使用该wcf服务来绘制图 以下是我的配置文件我在使用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> 

的follwoing是我的CS码

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

回答

0
+0

Hai web开发人员我对wcf有点新。你能帮我在我的web.config文件中修改的地方吗?如果我复制并粘贴在该网站的代码它显示一个错误.. – aravind

+0

Sry亚尔..我不知道silverlight甚至..请说web.config文件中的修改。感谢您的快速回复... – aravind

+0

这个例子可能会帮助你:http://www.codeproject.com/Articles/223572/Calling-Cross-Domain-WCF-service-using-Jquery-Java –