While returning a DataContract from a WCF function, I'm getting this error: "An error occurred while receiving the HTTP response"

StackOverflow https://stackoverflow.com/questions/17170479

  •  01-06-2022
  •  | 
  •  

Question

Here are my data contracts:

[DataContract]
public class Claim : IDisposable
{
    [DataMember]
    public int ClaimID { get; set; }

    [DataMember]
    public Stream ClaimImage { get; set; }

    [DataMember]
    public int PageNumber { get; set; }

    public void Dispose()
    {
        if (ClaimImage != null)
        {
            ClaimImage.Close();
            ClaimImage = null;
        }
    }
}

[DataContract]
public class ClaimInformation
{
    [DataMember]
    public List<string> Documents { get; set; }

    [DataMember]
    public int TotalPages { get; set; }
}

I have an OperationContract that takes a "ClaimInformation" and returns a list of "Claim." Which is just two integers and an image that is broken down into a stream.

[OperationContract]
List<Claim> ProcessDocument(ClaimInformation ClaimInfo);

ProcessDocument calls a method in a class.

public List<Claim> ProcessDocument(ClaimInformation ClaimInfo)
{
    List<Claim> FinishedClaimList = new List<Claim>();

    Document doc = new Document();
    FinishedClaimList = doc.ProcessDocument(ClaimInfo);

    return FinishedClaimList;
}

That method is too large for me to post here. But it's just this:

public List<Claim> ProcessDocument(ClaimInformation ClaimInfo)
    {

Inside of the method, it creates a new "Claim" and adds it to the "ClaimList."

ClaimList.Add(new Claim { ClaimID = ClaimID, ClaimImage = this.GetStream(newdoc.FullName), PageNumber = pageNum });

And finally, this is how I'm calling it all:

OCREngine.IEngine engine = new OCREngine.EngineClient();
OCREngine.ClaimInformation CI = new ClaimInformation();
CI.Documents = ImageNames;
CI.TotalPages = cc.lbClaims.Items.Count;

ClaimList.Add(engine.ProcessDocument(CI));

I'm just creating a new client for the service and then instantiating a new ClaimInformation DataContract. I set the ImageNames property, which is just a list of strings and then I add an integer to the TotalPages.

Any ideas on what I'm doing wrong here?

Était-ce utile?

La solution

That's a pretty generic exception in WCF so you'll need to enable WCF tracing to get more detailed info.

Just guessing but look at this MSDN forum thread where the list contained complex objects that exceeded the default internal object limits in WCF. Once you enable WCF tracing, you should have a better idea of what's going on.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top