2

I have an Operation Contract in my WCF service which returns an instance of the class which is actually a Message Contract. (Not Data Contract). The Message Contract has properties with attribute > [MessageBodyMember]

[MessageContract(WrapperName="AuthorizarionResponse", IsWrapped="true")]
public class AuthorizationResponse
{
  [MessageBodyMember] public string role {get;set;};
  [MessageBodyMember] public Organization organization {get; set;};
}

[ServiceContract]
interface IAuthorization
{
    [OperationContract]
    public AuthoriztionResponse GetAuthorizationResult(AuthorizationRequestMessage request);          

}

Organization class uses the XmlSerializer. It does not use DataContract because I want WCF service to be used from existing ASMX clients. When I debug the service and see the return value in the Operation Contract method, i can see everything which i want to return from the service through this operation contract.

But at the client side, I get null value!

Everything is ending without any exception/error. Fiddler2 does not give any red/error marks! What would be going wrong?

Learner
  • 4,661
  • 9
  • 56
  • 102

2 Answers2

3

The issue is Service sending the reply soap message not formed as expected by client Contract code. The serializer parses the Soap message based on Contract defined in Proxy code in client application, however, if the soap message received is not as expected, serializer Silently skips the content and moves forward. So, there is no error and also object is not filled because serializer didn't find expected contents.

So, you'd need to identify how client expects soap message formed..

amit
  • 2,093
  • 16
  • 10
  • Your reply is very helpful. Thanks for it. I upvoted for your answer! I am quite new to WCF. Can you please tell me easy way to identify the SOAP message format which client is expecting? Is it possible to identify it looking at the WSDL or the client side proxy classes? – Learner Mar 28 '11 at 04:12
  • 1
    Yes, it's possible to identify how client application is expecting the Soap message by looking at the code. However, the easiest way I follow is creating Service stub from WSDL (using WSDl.exe /serverInterface) and creating service from it. Once you've created the service, just browse the Service in IE and click on the operation. It should list the expected request and response soap message. HTH - Amit – amit Mar 29 '11 at 19:17
  • Accepting your response as answer and editing it further to mention solution. – Learner Mar 31 '11 at 08:33
1

You can enable trace logging as described here

<system.diagnostics>
    <sources>
        <source     name="System.ServiceModel"
                    switchValue="Information, ActivityTracing"
                    propagateActivity="true">
            <listeners>
                <add    name="traceListener"
                        type="System.Diagnostics.XmlWriterTraceListener"
                        initializeData= "c:\wcf.svclog" />
            </listeners>
        </source>
    </sources>
</system.diagnostics>

then use SvcTraceViewer.exe from C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin or one of its siblings folders

bresleveloper
  • 5,940
  • 3
  • 33
  • 47