2013-11-04 3 views
0

나는 stackoverflow에서 많은 답변을 보았지만 나에게 도움이되지 못했습니다. 나는 wcf 서비스를 가지고있다. 언제 실행 중인지 브라우저에서 유효한 출력을 보여주고있다. 나는 jquery 클라이언트에서 그것을 소비하고있다. 어떤 출력도 제공하지 않는다. wcf 서비스를 사용하여 그래프를 그려야한다. 내 클라이언트 측 코드 내 CS 코드 내 설정 파일 WCF 서비스를 사용하는 중에 오류가 발생했습니다.

[ServiceContract] 
    public interface IService1 
    { 

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

    } 

다음

입니다

<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> 

가 때라도입니다 다음

$(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

서비스를 크로스 도메인으로 구성하십시오. http://lucbei.wordpress.com/2010/09/04/cross-domain-wcf-restful-with-jsonp-2/

+0

안녕 웹 개발자 저는 wcf에 조금 익숙합니다. 내 web.config 파일에서 수정해야하는 부분을 도와주십시오. 해당 사이트의 코드를 복사하여 붙여 넣으면 오류가 표시됩니다. – aravind

+0

Sry Yar .. silverlight도 알지 못합니다. web.config 파일의 수정 내용을 말하십시오. 빠른 답장을 보내 주셔서 감사합니다. – aravind

+0

이 예제는 당신을 도울 수 있습니다 : http://www.codeproject.com/Articles/223572/Calling-Cross-Domain-WCF-service-using-Jquery-Java –

관련 문제