2011-03-25 3 views
2

기본적으로 모든 것이 잘 작동하지만 서버에 wcf 데이터 서비스를 배포하면 응답은 atom + xml입니다. 내가 놓친 게 있니? Web.config의 WCFjquery wcf 데이터 서비스는 json 대신에 atom + xml을 반환합니다.

JQuery와

 $(function() { 
       $.ajax({      
        contentType: "application/json; charset=utf-8", 
        url: "http://subdomain.domain.com/wcfdataservice.svc/surveys/", 
        dataType: "jsonp", 
        success: function (data, textStatus) { 

        }, 
        error: function (data, textStatus) { 

        } 
       });  

     }); 

<system.web> 
    <compilation debug="false" targetFramework="4.0" /> 

<authentication mode="None"/> 

</system.web> 
<system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"> 
     <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> 
    </modules> 
</system.webServer> 
<system.serviceModel> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> 
    <standardEndpoints> 
     <webHttpEndpoint> 
      <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" crossDomainScriptAccessEnabled="true" /> 
     </webHttpEndpoint> 
    </standardEndpoints> 

</system.serviceModel> 

피들러

 HTTP/1.1 200 OK 
Cache-Control: no-cache 
Content-Length: 13483 
Content-Type: application/atom+xml;charset=utf-8 
Server: Microsoft-IIS/7.5 
DataServiceVersion: 2.0; 
X-AspNet-Version: 4.0.30319 
X-Powered-By: ASP.NET 
Date: Fri, 25 Mar 2011 17:46:37 GMT 

<?xml version="1.0" encoding="utf-8" standalone="yes"?> 
<feed xml:base="http://subdomain.domain.com/wcfdataservice.svc/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom"> 
... 

답변

2

나는 파블로 카스트로의이 질문에 answer 당신이 찾고있는 솔루션입니다 생각합니다.

기본적으로 요청시 "신청/json"헤더를 지정하고 선택적으로 서비스에 [JSONPSupportBehavior] 속성을 사용해야합니다. 내 생각에, 당신이 양쪽 끝을 통제하고 있기 때문에 받아들이는 헤더 만 있으면 충분합니다.

편집 : 당신이 검사하는 경우, 피들러와 함께, 귀하의 요청에 당신은 당신이이 문서에이 기술을 사용할 수 있습니다의 헤더가 올바르게 설정되어있는 설정 여부중인 '동의'표시되지 않습니다 :

http://snipplr.com/view/9869/set-jquery-ajax-header/

희망이 있습니다.

0

WCF WebApi (미리보기 6)를 사용하면 훨씬 쉽습니다. NuGet을 사용하여 WCF WebApi를 설치해야하지만, 그만한 가치가 있습니다. 설치가 완료되면 자세한 내용은 here을 참조하십시오.

관련 문제