Why doesn't WCF work the same as ASMX?

Not sure what I am doing wrong, but I have two services, WCF and the other is an ASMX service.

I am trying to call an array of twos in the same way as in my version of asmx.

Here is a picture of two services:

enter image description here

I have a problem with being able to call this method, but I would like to know why ArrayOfDouble

it is not displayed in the same way in my serviceref2 as my serviceref1?

This is the WCF version:

namespace WcfSum
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
    [ServiceContract]
    public interface SumListWCF
    {

        [OperationContract]
        string CalculateSum(List<double> listDouble);
    }
}

namespace WcfSum
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
    public class SumList : SumListWCF
    {
        public string CalculateSum(List<double> listDouble)
        {
            return listDouble.Sum().ToString();
        }
    }
}

      

This is the ASMX version:

namespace CalculateWebServiceSum
{
    /// <summary>
    /// Summary description for Service1
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class SumList : System.Web.Services.WebService
    {
        [WebMethod]
        public string CalculateSum(List<double> listDouble)
        {
            return listDouble.Sum().ToString();

             //return listDouble.Select(n => (double)n).ToString();
        }
    }
}

      

Previous post was here: WCF array of doubles was not invoked successfully

This provided a fix, but doesn't explain why it doesn't work the same way. Or if there is a way to make him act the same way. What makes me feel like they are basically missing something?

EDIT

Ps, they just run locally.

+3


source to share


2 answers


There is nothing in the SOAP or WSDL standards that dictates how something like List<double>

. ASMX apparently came up complexType

with an XML schema to represent a double array.

WCF is much better than ASMX. When you use Add Service Reference, you can decide how to handle duplicate items such as your array of paired numbers. You can choose for them to be treated as an array, like List<T>

etc.



It would be negative to limit WCF to ASMX constraints, which is a legacy technology.

+4


source


The shared parameter List <> is used, which is not supported for asmx and wcf due to interactions with languages ​​that do not support shared collections. See also these questions .



This question mentions a generated ArrayOfInt, so the type name ArrayOf * might be a generic uhm solution for working with generic types.

0


source







All Articles