Hi everyone,
I am still a bit confused about the use of the service policy for the REST services.
It is possible to configure http status code to be included/excluded from the exception, and I thought this was related to the property "Throw exception on Fault" available on the "ServiceEndpoint process step".
I would like to control the behavior of a service replacing the following custom code, is it possible?
if (context.Data.Header.FaultType != FaultType.None) {
switch (context.Data.Http.StatusCode) {
case System.Net.HttpStatusCode.InternalServerError:
case System.Net.HttpStatusCode.BadRequest:
throw new ApplicationException(string.Format("Unexpected error during call, ther server returned a {0} HTTP code.", context.Data.Http.StatusCode));
case System.Net.HttpStatusCode.NotFound:
context.Data.Text = "<Subscriptions></Subscriptions>";
break;
}
}
I created a policy excluding 404 code, as in img (2) and applied the policy to the endpoint. With the "Throw exception on Fault" = true, it's still throwing an exception as happens if I do not change anything (1). I would expected the service to continue the normal flow, am I missing something?
Thank you very much
Fabrizio
Tags:
Sorry guys if I insist but I would like to understand how this works...
I have a REST Endpoint configured with a specific Service policy. The policy exclude the 404 HTTP code as an exception.
What I would expect is that when invoked, if it returns a 500 code, then an exception is thrown and the process aborts, while if it returns a 404 nothing happens and the process continues.
I can't get it to work.. this is the expcetion that I get when the service replies with 404 and the process aborts.
Aborted: The service connector reported an error: There was no endpoint listening at http://localhost:8080/RESTMockService that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. : Neuron.Pipelines.PipelineException: The service connector reported an error: There was no endpoint listening at http://localhost:8080/RESTMockService that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. ---> System.ServiceModel.EndpointNotFoundException: There was no endpoint listening at http://localhost:8080/RESTMockService that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. ---> System.Net.WebException: The remote server returned an error: (404) Not Found.
at System.Net.HttpWebRequest.GetResponse()
What am I missing?
I would like to avoid writing custom code to manage this simple scenario, I would like to consider a 4040 a valid answer for thi particular service.. shouldn't the policy solve it?Neuron ESB Product Support Forums and Communities
© 2024 Created by Neuron Admin. Powered by