none
Problem serializing message on WCF service side when calling from WCF Adapter RRS feed

  • Question

  • I have a simple WCF service that uses a data contract class in the operation signature to serialize the message coming in. I am calling the operation using the WCF WS-Http Adapter; on the service side, I am getting a null object error. I'm sure its the way I have the WCF adapter configured, but I can't figure out what it needs.

    Here is my service contract:

    [ServiceContract(Name="DataManager", Namespace = "http://Applicant")]
        public interface IDataManager
        {

            [OperationContract]
            [TransactionFlow(TransactionFlowOption.Mandatory)]
            [FaultContract(typeof(FaultException))]
            Applicant SubmitMessage(Applicant message);

    }

    Here is my implementation operation:

    Applicant SubmitMessage(Applicant message)
            {
                ProcessMessage(message);
                return message;
            }


    Here is my Data Contract class:

    [System.Diagnostics.DebuggerStepThroughAttribute()]
        [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")]
        [System.Runtime.Serialization.DataContractAttribute(Name="Applicant", Namespace="http://mynamespace.Applicant")]
        public partial class Applicant : object, System.Runtime.Serialization.IExtensibleDataObject
        {
           
            private System.Runtime.Serialization.ExtensionDataObject extensionDataField;
           
            private string ActionField;
           
            private int IDField;
           
            private string FirstNameField;
           
            private string LastNameField;
           
            private string ResponseField;
           
            public System.Runtime.Serialization.ExtensionDataObject ExtensionData
            {
                get
                {
                    return this.extensionDataField;
                }
                set
                {
                    this.extensionDataField = value;
                }
            }
           
            [System.Runtime.Serialization.DataMemberAttribute(IsRequired=true, EmitDefaultValue=false)]
            public string Action
            {
                get
                {
                    return this.ActionField;
                }
                set
                {
                    this.ActionField = value;
                }
            }
           
            [System.Runtime.Serialization.DataMemberAttribute(IsRequired=true)]
            public int ID
            {
                get
                {
                    return this.IDField;
                }
                set
                {
                    this.IDField = value;
                }
            }
           
            [System.Runtime.Serialization.DataMemberAttribute(IsRequired=true, EmitDefaultValue=false, Order=2)]
            public string FirstName
            {
                get
                {
                    return this.FirstNameField;
                }
                set
                {
                    this.FirstNameField = value;
                }
            }
           
            [System.Runtime.Serialization.DataMemberAttribute(IsRequired=true, EmitDefaultValue=false, Order=3)]
            public string LastName
            {
                get
                {
                    return this.LastNameField;
                }
                set
                {
                    this.LastNameField = value;
                }
            }
           
            [System.Runtime.Serialization.DataMemberAttribute(IsRequired=true, EmitDefaultValue=false, Order=4)]
            public string Response
            {
                get
                {
                    return this.ResponseField;
                }
                set
                {
                    this.ResponseField = value;
                }
            }
        }


    Here is my WCF Adapter configuration:

    Type: WCF-WSHttp
    URI: http://localhost/DataManager/DataManager.svc
    Action: http://Applicant/DataManager/SubmitMessage

    Outbound message: Template
    <SubmitMessage xmlns="http://Applicant" >
    <bts-msg-body xmlns="http://www.microsoft.com/schemas/bts2007" encoding="xml"/>
    </SubmitMessage>

    Inbound message: Body


    Here is a sample XML message that I submit to the service:


    <Applicant xmlns="http://mynamespace.Applicant">
      <Action>add</Action>
      <ID>0</ID>
      <FirstName>Test</FirstName>
      <LastName>Asynchronous typed messaging march 03</LastName>
      <Response>request</Response>
    </Applicant>


    Any assistance would be appreciated. Thanks!

    Tuesday, March 3, 2009 7:16 PM

Answers

All replies

  • Did you specify the Operation element detail in the BTS Action Mapping like at http://msdn.microsoft.com/en-us/library/bb743856.aspx?

    Thanks,
    If this answers your question, please use the "Answer" button to say so | Ben Cline
    Wednesday, March 4, 2009 5:48 AM
    Moderator
  • No, my understanding is that simply maps the operation name to the Action, which is not necessary for me, I am hitting the service operation just fine with: Action: http://Applicant/DataManager/SubmitMessage

    When the code reaches the service operation, the XML does not get serialized to the Data Contract object. How would mapping the Operation with the Action help?
    Thursday, March 5, 2009 7:52 PM