현재 REST WCF 서비스가 작동 중입니다. 사용자 지정 JSON 개체를 반환하는 오류 처리를위한 사용자 지정 동작을 구현하려고합니다. 나는이 기사에서 WCF Exception Handling with IErrorHandler이 트릭을 할 것이라고 생각하지만 예제는 코드를 통해 동작을 추가하는 방법을 보여줍니다. 우리는 IIS를 통해 서비스를 호스팅하고 있으며 ServiceHost가 없습니다. 누구든지 내 사용자 지정 오류 처리 클래스를 web.config에 추가하는 방법에 관해서는 저에게 지시 할 수 있습니까?표준 webHttpEndpoint를 사용하는 사용자 지정 끝점 동작
나는 Google과 SO를 모두 조사했으며 내가 수행하려고하는 것과 밀접하게 관련된 많은 예제를 발견했지만 WCF에 대한 나의 이해는 아마도 완전히 이해하지 못하게 할 것입니다.
다음은 엔드 포인트에 대해 구성한 모든 것입니다.
<standardEndpoints>
<webHttpEndpoint>
<!--
Configure the WCF REST service base address via the global.asax.cs file and the default endpoint
via the attributes on the <standardEndpoint> element below
-->
<standardEndpoint helpEnabled="true" automaticFormatSelectionEnabled="false"/>
</webHttpEndpoint>
</standardEndpoints>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
당신은 certanly이 수행
이 서비스에 동작 구성을 적용합니다
이 동작 구성에 동작 확장 적용 :
것은 행동의 확장 만들기 모든 호출에 대한 서비스 호스트. 그것은 당신을 위해 무대 뒤에서 만들어졌습니다. svc 파일에서 서비스 호스트를 정의하여 사용자 자신의 인스턴스를 인스턴스화 할 수 있습니다. – ChristoD