ASMX schema varies when using WCF Service

Posted by Lijo on Stack Overflow See other posts from Stack Overflow or by Lijo
Published on 2010-06-06T10:45:29Z Indexed on 2010/06/06 10:52 UTC
Read the original article Hit count: 268

Filed under:

Hi,

I have a client (created using ASMX "Add Web Reference"). The service is WCF. The signature of the methods varies for the client and the Service. I get some unwanted parameteres to the method.

Note: I have used IsRequired = true for DataMember.

Service: [OperationContract] int GetInt();

Client: proxy.GetInt(out requiredResult, out resultBool);

Could you please help me to make the schame non-varying in both WCF clinet and non-WCF cliet? Do we have any best practices for that?

using System.ServiceModel;
using System.Runtime.Serialization;
namespace SimpleLibraryService
{
        [ServiceContract(Namespace = "http://Lijo.Samples")]
        public interface IElementaryService
        {
            [OperationContract]
            int GetInt();

            [OperationContract]
            int SecondTestInt();
        }

        public class NameDecorator : IElementaryService
        {
            [DataMember(IsRequired=true)]
            int resultIntVal = 1;

            int firstVal = 1;

            public int GetInt()
            {
                return firstVal;
            }

            public int SecondTestInt()
            {
                return resultIntVal;
            }
        }

}

Binding = "basicHttpBinding"

using NonWCFClient.WebServiceTEST;
namespace NonWCFClient
{
    class Program
    {
        static void Main(string[] args)
        {
            NonWCFClient.WebServiceTEST.NameDecorator proxy = new NameDecorator();

            int requiredResult =0;
            bool resultBool = false;
            proxy.GetInt(out requiredResult, out resultBool);
            Console.WriteLine("GetInt___"+requiredResult.ToString() +"__" + resultBool.ToString());

            int secondResult =0;
            bool secondBool = false;
            proxy.SecondTestInt(out secondResult, out secondBool);
            Console.WriteLine("SecondTestInt___" + secondResult.ToString() + "__" + secondBool.ToString());

            Console.ReadLine();

        }
    }
}

Please help..

Thanks

Lijo

© Stack Overflow or respective owner

Related posts about wcfservice