JeremyK
JeremyK

Reputation: 1103

WCF Service Reference call returning "The remote server returned an error: NotFound."

I am pulling my hair out over this one.

I have a WCF interface for calls on a web server. All the other functions are working fine, but the new function I added is resulting in "The remote server returned an error: NotFound." in the Reference.cs auto generated file in the End function.

I know the server is found, I have the debugger breaking on the service side and its clearly being called and returning the correct type.

What else could cause this misleading error?

[ServiceContract]
public interface IDatabaseQueries
{
...
    [OperationContract(AsyncPattern = true)]
    IAsyncResult BeginGetItemFromId(int itemID, AsyncCallback callback, Object state);

    RmaItem EndGetItemFromId(IAsyncResult result);
...
}

[DataContract]
[KnownType(typeof(ItemType))]
[KnownType(typeof(Location))]
[KnownType(typeof(DateTime))]
public class RmaItem
{
...
}

[SilverlightFaultBehavior]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[KnownType(typeof(RmaItem))]
[KnownType(typeof(RmaReport))]
public class DatabaseService : IDatabaseQueries
{
...
public IAsyncResult BeginGetItemFromId(int itemID, AsyncCallback callback, Object state)
{
    return new DatabaseResponse(itemID);
}

public RmaItem EndGetItemFromId(IAsyncResult result)
{
    return GetRmaItemById((int)(result as DatabaseResponse).GetData);
}
...
}

Crashing in "Reference.cs":

public RMA.DatabaseServiceReference.RmaItem EndGetItemFromId(System.IAsyncResult result) {
                object[] _args = new object[0];
                RMA.DatabaseServiceReference.RmaItem _result = ((RMA.DatabaseServiceReference.RmaItem)(base.EndInvoke("GetItemFromId", _args, result)));
                return _result;

Edit:

When I say all other functions I mean additional functions is the same IDatabaseQueries interface.

EDIT 2::

Turns out the problem was using a Enum as a field (ItemType). As shown above, I have ItemType as a known type. Is there a special condition I am missing on that type? Here is the deceleration.

[DataContract]
public enum ItemType
{
    LOCATION, PART, ASSEMBLY
}

Upvotes: 0

Views: 1669

Answers (2)

JeremyK
JeremyK

Reputation: 1103

Resolved.

I was missing the EnumMember with each value in the ItemType enumaration.

    [DataContract]
    public enum ItemType
    {
        [EnumMember]
        LOCATION,
        [EnumMember]
        PART,
        [EnumMember]
        ASSEMBLY
    }

Thank you for the response McAden

Upvotes: 0

McAden
McAden

Reputation: 13972

Silverlight doesn't understand all errors. The problem isn't that the server is returning "Not Found" but that silverlight's trying to look up the error that wcf returned and it can't find it.

You can follow a method like this to find out more info or use a packet sniffer like Fiddler.

Upvotes: 2

Related Questions