0

I am using a third party service & hence has no access to change anything from service side. I WSDL which I added as connect service.

The problem is that I have enabled the raw request & I can see error details in trace or debug log. But When I try to fetch details using following code it always return empty Detail Object.

try {
   // my code to call service
}
catch (System.ServiceModel.FaultException<Error[]> errors) {
    var err = Newtonsoft.Json.JsonConvert.SerializeObject(errors.Detail)
    Console.WriteLine(err);
}
Khurram Ilyas
  • 117
  • 3
  • 19
  • Can you give an example of the output received? What's in `Detail`, `{}`? – Jimenemex Feb 09 '21 at 03:02
  • I'd also be curious to what the WSDL reference file looks like for the `XmlTypeAttribute` for the supposed `TypeName = "ErrorDetail"`. It sounds like a problem deserializing from the type returned from your vendor to the type specified in the WSDL. – Jimenemex Feb 09 '21 at 03:34
  • If you `catch (Exception ex)` what kind of exception do you see? Soap faults were really badly implemented, it never threw exception the way we wanted so we had to return a result with error as result. – Akash Kava Feb 10 '21 at 04:42
  • Looks like a duplicate of https://stackoverflow.com/questions/3669955/faultexception-detail-coming-back-empty – VisualBean Feb 10 '21 at 16:11

1 Answers1

0

Edit: looks to be a duplicate of FaultException.Detail coming back empty

The problem was the visual studio didn't quite map out the ErrorDetail objects right. The ErrorDetail node is called "ErrorDetail", but the type generated for it is "ErrorDetailType." I edited the reference.cs class generated for each service I was using and added a TypeName:

VisualBean
  • 4,908
  • 2
  • 28
  • 57
  • Can you please explain in detail. I have a Reference.cs in which I can see a class called Error. I can't find anything called "ErrorDetailType" or not even "ErrorDetail". I did Find for "ErrorDetailType" and "ErrorDetail" in the complete file but found no results. – Khurram Ilyas Feb 11 '21 at 12:26