jQuery를 사용하여 클라이언트 응용 프로그램에서 WCF REST 스타터 키트를 기반으로하는 REST WCF 서비스로 데이터를 보내려고합니다.JSON 데이터를 WCF REST에 게시
여기까지 제가 지금까지 가지고 있습니다.
서비스 정의 : JSON의
$.ajax({
url:SVC_PROPERTYVALUES_SAVE,
type: "POST",
contentType: "application/json; charset=utf-8",
data: jsonData,
dataType: "json",
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert(textStatus + ' ' + errorThrown);
},
success: function(data) {
if (data) {
alert('Values saved'); $("#confirmSubmit").dialog('close');
}
else {
alert('Values failed to save'); $("#confirmSubmit").dialog('close');
}
}
});
예는 전달되는 : 클라이언트에서
[WebHelp(Comment = "Save PropertyValues to the database")]
[WebInvoke(Method = "POST", UriTemplate = "PropertyValues_Save",
BodyStyle = WebMessageBodyStyle.WrappedRequest,
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json)]
[OperationContract]
public bool PropertyValues_Save(Guid assetId,
Dictionary<Guid, string> newValues) {
// ...
}
전화
{
"assetId": "d70714c3-e403-4cc5-b8a9-9713d05b2ee0",
"newValues": [
{
"key": "bd01aa88-b48d-47c7-8d3f-eadf47a46680",
"value": "0e9fdf34-2d12-4639-8d70-19b88e753ab1"
},
{
"key": "06e8eda2-a004-450e-90ab-64df357013cf",
"value": "1d490aec-f40e-47d5-865c-07fe9624f955"
}
]
}
의 Web.config
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings"
type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
</sectionGroup>
</configSections>
<system.web>
<compilation debug="true"/>
</system.web>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
</system.serviceModel>
<appSettings>
...
</appSettings>
</configuration>
가상 디렉터리에서 Windows 인증을 사용 중이며 익명 액세스가 사용되지 않습니다. GET 작업을 호출하면 모든 것이 정상입니다. 이 코드는 브라우저에 로그인하라는 메시지를 표시합니다. 자격 증명을 입력하면 브라우저에 "error undefined"라는 경고가 표시됩니다.
내 구체적인 오류를 도울 수 없더라도, 눈에 보이는 것처럼 보이는 부분이 보이지 않습니까?
저는 거의 하루 종일 저의 머리를 때리고 있습니다.
미리 감사드립니다.
인증은 통합이고 예, 익명입니다. 이 특정 방법에 대한 로그인 프롬프트 만 표시됩니다. XML 버전 = "1.0"> <구성> ... \t \t \t <편집 디버그 = "진정한"/> \t <시스템 : Web.config의 당신을위한 물었다. ServiceModel은 서비스> \t \t \t 구성> –
그것은 맞습니다.''블록 안에' '블록이 있기를 바랍니다. 그렇지 않으면 이것을 추가하십시오. 'PropertyValues_Save'는 문제없이 작동합니까? (인증 문제 만) –
Oleg
예, 메서드 자체는 단위 테스트 내에서 제대로 작동합니다. –