0

Visual Studio と C# でプログラミングするのはこれが初めてです。Web サービスを作成しようとしていますが、GetProduct が表示されません。

  namespace GettingStartedHost
 {
// 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 Service1 : IService1
{
    public string GetData(int value)
    {
        return string.Format("You entered: {0}", value);
    }

    public int GetProduct(int a, int b)
    {
        return a * b;
    }

    [ServiceContract]
    public interface IService
    {
        [OperationContract]
        int GetProduct(int a, int b);

        [OperationContract]
        string GetData(int value);

        [OperationContract]
        CompositeType GetDataUsingDataContract(CompositeType composite);



    }


    public CompositeType GetDataUsingDataContract(CompositeType composite)
    {
        if (composite == null)
        {
            throw new ArgumentNullException("composite");
        }
        if (composite.BoolValue)
        {
            composite.StringValue += "Suffix";
        }
        return composite;
    }

}

}

CTRL-F5 を押してテスト サーバーを起動すると、2 つのメソッドしか表示されません。GetProduct が表示されません。なにが問題ですか?

4

1 に答える 1

-1

このコードを試してください。

namespace GettingStartedHost
{
    // 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 Service1 : IService1
    {
        public string GetData(int value)
        {
            return string.Format("You entered: {0}", value);
        }

        public int GetProduct(int a, int b)
        {
            return a * b;
        }

        public CompositeType GetDataUsingDataContract(CompositeType composite)
        {
            if (composite == null)
            {
                throw new ArgumentNullException("composite");
            }
            if (composite.BoolValue)
            {
                composite.StringValue += "Suffix";
            }
            return composite;
        }
    }

    [ServiceContract]
    public interface IService1
    {
        [OperationContract]
        int GetProduct(int a, int b);

        [OperationContract]
        string GetData(int value);

        [OperationContract]
        CompositeType GetDataUsingDataContract(CompositeType composite);
    }

}
于 2012-10-16T23:22:37.513 に答える