Craig List
Craig List

Reputation: 81

webservice method overload possible issues with non .net webservices

I am designing a web service which has overloaded method and someone said we should try not to overload methods in web service as there can be issues generating wsdl or if non .net service tries to consume those methods.

I tested the scenario of generating the wsdl by creating a simple service with two add methods one taking integer and other double and had no issues.

so wanted to check 1. if i am missing something in the wsdl which i am overlooking. 2. Are there any known issues with non .net webservice cosuming service with overloaded functions. 3.Is it not recommended to use overloaded functions if you can?

following is what my test service looks like --service library

using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;

namespace EvalServiceLibrary
{
     [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
    public class EvalService: IEvalService
    {

        public int AddEval(int a, int b, int c)
        {
            return a + b + c;
        }

        public double AddEval(double a, double b, double c)
        {
            return a + b + c;
        }
    }
}

--inerface code is

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;

namespace EvalServiceLibrary
{
    [ServiceContract]
    public interface IEvalService
    {
        [OperationContract(Name = "Addint")]
        int AddEval(int a, int b, int c);
        [OperationContract(Name = "Addfloat")]
        double AddEval(double a, double b, double c);

    }
}

--service code

using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;

namespace EvalServiceLibrary
{
     [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
    public class EvalService: IEvalService
    {

        public int AddEval(int a, int b, int c)
        {
            return a + b + c;
        }

        public double AddEval(double a, double b, double c)
        {
            return a + b + c;
        }
    }
}

Upvotes: 0

Views: 91

Answers (1)

Yaron Naveh
Yaron Naveh

Reputation: 24416

You will not have problems since OperationContract has different name for each operation (this is the name that counts). WSDL consumers will have no idea that you use an overload for implementation. You can also open the WSDL and see those are two distinguished operations.

Upvotes: 1

Related Questions