14

I am trying to use the WCF Test Client to test a WCF service I have built.

The service has one method "SubmitRequest".

[OperationContract]
Response SubmitRequest(Request request);

When I load up the WCF Test Client, the method is grayed out with the message "This operation is not supported in the WCF Test Client because it uses type WcfLibrary.Objects.Request

Below is the type definition, does anyone see anything wrong?

[DataContract]
public class Request
{
    [DataMember]
    public string LoanNumber { get; set; }

    [DataMember]
    public string ClientCode { get; set; }

    [DataMember]
    public Region Region { get; set; }

    [DataMember]
    public RequestType RequestType { get; set; }

    [DataMember]
    public List<RequestParameter> RequestParameters { get; set; }

    [DataMember]
    public List<MspWebCallType> MspWebCallsForXmlRequest { get; set; }

    [DataMember]
    public Hashtable XmlRequestParameters { get; set; }

    public Request(string loanNumber, string clientCode, Region region, RequestType requestType, List<RequestParameter> requestParameters)
    {
        LoanNumber = loanNumber;
        ClientCode = clientCode;
        Region = region;
        RequestType = requestType;
        RequestParameters = requestParameters;
    }
}

[DataContract]
public class MspWebCallType
{
    [DataMember]
    public string WebService { get; set; }
    [DataMember]
    public string Operation { get; set; }
    [DataMember]
    public string Version { get; set; }
    [DataMember]
    public Hashtable Parameters { get; set; }
    [DataMember]
    public Msp.FavReadViews FAVReadViewIndicator { get; set; }
    [DataMember]
    public Msp.DsReadIndicators DSReadInidicator { get; set; }        
}

[DataContract]
public enum Region 
{ 
        [EnumMember]
        P2,
        [EnumMember]
        PROD 
}

[DataContract]
public enum RequestType
{
    [EnumMember]
    None,
    [EnumMember]
    XmlRequest,
    [EnumMember]
    SomeOtherRequestType
}

[DataContract]
public struct RequestParameter
{
    [DataMember]
    public string ParameterName { get; set; }

    [DataMember]
    public string ParameterValue { get; set; }
}

Thanks.

EDIT w/ answer...
The operation was not available via the WCF Test Client because the type MspWebCallType had a property of type Hashtable. Once I removed this property it fixed the issue. Thanks for everyone's help.

thiag0
  • 2,199
  • 5
  • 31
  • 51
  • Does the WSDL reference an XSD for the 'Request' class? – M.Babcock Dec 19 '11 at 21:43
  • Have you tried: [OperationContract] [KnownType(typeof(Request))] Response SubmitRequest(Request request); – Ta01 Dec 19 '11 at 21:51
  • A question: Is your Request class actually inside the namespace WcfLibrary.Objects? – Andrew Shepherd Dec 19 '11 at 21:52
  • @M.Babcock - I do not see any entries in the WSDL for the 'Request' class. – thiag0 Dec 19 '11 at 21:53
  • Here's a long shot - the framework gets confused because "Request" is such an overloaded term. What happens if you change the type to "Request_X"? – Andrew Shepherd Dec 19 '11 at 21:55
  • @kd7 - When I add the [KnownType] attribute I get the following error: "Attribute 'KnownType' is not valid on this declaration type. It is only valid on 'class, struct' declarations." – thiag0 Dec 19 '11 at 21:55
  • @AndrewShepherd - The type is not named 'Request', I changed it for the post to keep it simple. Thanks. – thiag0 Dec 19 '11 at 21:57
  • Commenting about your answer; does that mean only test client doesnt work or also wcf isnt supporting that type? Do you fetch that type on your WSDL? – Emil Nov 14 '13 at 14:42
  • 2
    @batmaci The Hashtable type is still supported by WCF. It's the default test client that comes with Visual Studio (WcfTestClient http://msdn.microsoft.com/en-us/library/bb552364(v=vs.110).aspx) that doesn't support that type. – thiag0 Dec 03 '13 at 18:08

4 Answers4

27

The following is a list of features not supported by WCF Test Client:

  • Types: Stream, Message, XmlElement, XmlAttribute, XmlNode, types that implement the IXmlSerializable interface, including the related XmlSchemaProviderAttribute attribute, and the XDocument and XElement types and the ADO.NET DataTable type.

  • Duplex contract.

  • Transaction.

  • Security: CardSpace , Certificate, and Username/Password.

  • Bindings: WSFederationbinding, any Context bindings and Https binding, WebHttpbinding (Json response message support).

Source: MSDN

Check Msp.FavReadViews and Msp.DsReadIndicators to ensure they comply.

Igby Largeman
  • 16,495
  • 3
  • 60
  • 86
  • Msp.FavReadViews and Msp.DsReadIndicators are defined inside a referenced class library project. They are simple enums but do not have the EnumMember attributes. I removed these 2 properties from the Request type and still experience the same issue. Thanks. – thiag0 Dec 19 '11 at 22:02
  • @igby-largeman thanks for the in depth list, also it seems that the type of "Type" is not supported. If you get a chance please add it to your list. – Gent Jan 22 '14 at 14:29
  • Why in this link explain how to [Enable Streaming](http://msdn.microsoft.com/en-us/library/ms789010.aspx ) – Hamid Bahmanabady Feb 10 '14 at 08:31
0

Answering here as this is the first result on Google currently for this error:

In addition to @Igby Largeman 's answer, you will also receive this error if somewhere in your operation or data contracts, you have used a type that is not serializable.

Take an example of the Exception class in .NET...

I had a case whereby a developer on my team had opted to send back the Exception object to the service's client via a DTO, rather than put the exception message into the DTO manually. Visual Studio will not warn you at build time (it should, really), that the class is not serializable, it will only fail at runtime.

So if you are receiving this error and have ruled out the answer above, ensure you check the types used in your contracts and DTOs; something not being serializable could be your culprit.

I hope this saves someone some time.

Moby's Stunt Double
  • 2,540
  • 1
  • 16
  • 32
0

I had the same error and the problem was that the class had an System.Drawing.Image property. I remove it from the class and it worked. I convert the byte array to a base64 string.

Mike
  • 173
  • 2
  • 5
0

It might be because Request needs to have a public non-parametric constructor.

petr k.
  • 8,040
  • 7
  • 41
  • 52
  • I tried adding a parameterless constructor but that did not resolve the issue. – thiag0 Dec 20 '11 at 18:02
  • Well, is the WCF Test Client not supporting your service definition a big deal for you? It works for relatively simple service interfaces only.. I usually use SoapUI for testing my services. – petr k. Dec 20 '11 at 18:05