IncludeExceptionDetailInFaults를 켭니다 (ServiceBehaviorAttribute 또는 서버에서 구성 동작)
나는 완벽하게 작동하는 WCF 서비스를 가지고 있으며 무언가가 바뀌었고 무엇을 알지 못합니다.
이 예외가 발생합니다.
System.ServiceModel.FaultException : 서버가 내부 오류로 인해 요청을 처리 할 수 없습니다. 오류에 대한 자세한 내용을 보려면 서버에서 IncludeExceptionDetailInFaults (ServiceBehaviorAttribute 또는 구성 동작)를 설정하여 예외 정보를 다시 클라이언트로 보내거나 Microsoft .NET Framework 3.0 SDK 설명서에 따라 추적을 설정하십시오. 서버 추적 로그를 검사하십시오.
.NET 4.0을 실행하고 있기 때문에 혼란 스럽습니다.
어디서 켜 IncludeExceptionDetailInFaults
나요? 나는 그것을 찾기 위해 싸우고있다.
파일 에서 동작 을 정의하십시오 .config
.
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="debug">
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
...
</system.serviceModel>
</configuration>
그런 다음 다음 행을 따라 서비스에 동작을 적용하십시오.
<configuration>
<system.serviceModel>
...
<services>
<service name="MyServiceName" behaviorConfiguration="debug" />
</services>
</system.serviceModel>
</configuration>
프로그래밍 방식으로 설정할 수도 있습니다. 이 질문을 참조하십시오 .
app.config 파일에 있습니다.
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceDebug includeExceptionDetailInFaults="true"/>
코드로이 작업을 수행하려면 다음과 같은 동작을 추가하십시오.
serviceHost.Description.Behaviors.Remove(
typeof(ServiceDebugBehavior));
serviceHost.Description.Behaviors.Add(
new ServiceDebugBehavior { IncludeExceptionDetailInFaults = true });
인터페이스를 상속하는 클래스 선언 위의 [ServiceBehavior] 태그에서 설정할 수도 있습니다.
[ServiceBehavior(IncludeExceptionDetailInFaults = true)]
public class MyClass:IMyService
{
...
}
Immortal Blue는 실행 세부 사항을 공개적으로 출시 된 버전에 공개하지 않는 것이 맞지만 테스트 목적으로 편리한 도구입니다. 손을 떼면 항상 전원을 끄십시오.
I was also getting the same error, the WCF was working properly for me when i was using it in the Dev Environment with my credentials, but when someone else was using it in TEST, it was throwing the same error. I did a lot of research, and then instead of doing config updates, handled an exception in the WCF method with the help of fault exception. Also the identity for the WCF needs to be set with the same credentials which are having access in the database, someone might have changed your authority. Please find below the code for the same:
[ServiceContract]
public interface IService1
{
[OperationContract]
[FaultContract(typeof(ServiceData))]
ForDataset GetCCDBdata();
[OperationContract]
[FaultContract(typeof(ServiceData))]
string GetCCDBdataasXMLstring();
//[OperationContract]
//string GetData(int value);
//[OperationContract]
//CompositeType GetDataUsingDataContract(CompositeType composite);
// TODO: Add your service operations here
}
[DataContract]
public class ServiceData
{
[DataMember]
public bool Result { get; set; }
[DataMember]
public string ErrorMessage { get; set; }
[DataMember]
public string ErrorDetails { get; set; }
}
in your service1.svc.cs you can use this in the catch block:
catch (Exception ex)
{
myServiceData.Result = false;
myServiceData.ErrorMessage = "unforeseen error occured. Please try later.";
myServiceData.ErrorDetails = ex.ToString();
throw new FaultException<ServiceData>(myServiceData, ex.ToString());
}
And use this in the Client application like below code:
ConsoleApplicationWCFClient.CCDB_HIG_service.ForDataset ds = obj.GetCCDBdata();
string str = obj.GetCCDBdataasXMLstring();
}
catch (FaultException<ConsoleApplicationWCFClient.CCDB_HIG_service.ServiceData> Fex)
{
Console.WriteLine("ErrorMessage::" + Fex.Detail.ErrorMessage + Environment.NewLine);
Console.WriteLine("ErrorDetails::" + Environment.NewLine + Fex.Detail.ErrorDetails);
Console.ReadLine();
}
Just try this, it will help for sure to get the exact issue.
As the error information said first please try to increase the timeout value in the both the client side and service side as following:
<basicHttpBinding>
<binding name="basicHttpBinding_ACRMS" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647"
openTimeout="00:20:00"
receiveTimeout="00:20:00" closeTimeout="00:20:00"
sendTimeout="00:20:00">
<readerQuotas maxDepth="32" maxStringContentLength="2097152"
maxArrayLength="2097152" maxBytesPerRead="4006" maxNameTableCharCount="16384" />
</binding>
Then please do not forget to apply this binding configuration to the endpoint by doing the following:
<endpoint address="" binding="basicHttpBinding"
bindingConfiguration="basicHttpBinding_ACRMS"
contract="MonitorRAM.IService1" />
If the above can not help, it will be better if you can try to upload your main project here, then I want to have a test in my side.
'IT' 카테고리의 다른 글
여러 개의 인수가있는 Angular 2 파이프를 어떻게 호출합니까? (0) | 2020.06.08 |
---|---|
iOS에서 프로그래밍 방식으로 절전 모드를 비활성화 / 활성화하는 방법은 무엇입니까? (0) | 2020.06.08 |
""를 사용하여 문자열을 초기화하는 방법은 무엇입니까? (0) | 2020.06.08 |
열망하는 로딩이란 무엇입니까? (0) | 2020.06.08 |
두 정수 값을 나누어 플로트 결과를 얻는 방법은 무엇입니까? (0) | 2020.06.08 |