0

m sorry my Qs title is a bitt odd, i didnt found the right words to explain. Neways,

I have a WCF RESTful API in which I have implemented Custom Parameter Inspector class which inherits IParameterInspector to catch AfterCall and BeforeCall Methods.

public class CustomParameterInspector : IParameterInspector
{

    public void AfterCall(string operationName, object[] outputs, object returnValue, object correlationState)
    {}

    public object BeforeCall(string operationName, object[] inputs)
    {
        // I have to perform certain tasks here
    }
}

now my service interface is like this

    [OperationContract]
    [CustomInspectorAttribute]
    [WebInvoke(Method = "POST",
        UriTemplate = "GetMyDetail")]
    MyDetail GetMyDetail(MyDetail objMyDetail);

and service class is like this

public MyDetail GetMyDetail(MyDetail objMyDetail)
    {}

if I post JSON from client then it works fine.... in input[0] i get its type as MyDetail

But if change the input parameter to Object like this

[OperationContract]
    [CustomInspectorAttribute]
    [WebInvoke(Method = "POST",
        UriTemplate = "GetMyDetail")]
    MyDetail GetMyDetail(Object objMyDetail);


public MyDetail GetMyDetail(Object objMyDetail)
    {}

then it does not gives me null in inputs[0] in BeforeCall(string operationName, object[] inputs)

Can you tell me y is this so and how can i solve it, I really need to get it in object

1Mayur
  • 3,419
  • 5
  • 40
  • 64
  • Why u want to change it into an object? – VJAI Jun 07 '12 at 16:55
  • Do you mean you get a null when you change the type to object rather than MyDetail? – Rajesh Jun 08 '12 at 09:42
  • @Rajesh yes, that is the same scenerio – 1Mayur Jun 09 '12 at 05:42
  • @Mark have to implement obfuscation.. – 1Mayur Jun 09 '12 at 05:42
  • That might make sense as the framework needs to know on how to deserialize the incoming request to the associated object. As an alternative you can implement a MessageInspector that does the deserialization of the incoming request and send it as an object to the method. – Rajesh Jun 11 '12 at 10:00

0 Answers0