none
What is [Service.Web.Services.WebServicebindingAttribute] versus [ServiceContract]? RRS feed

  • Question

  • Hi,
    I'm trying to create a windows service.
    I have a .wsdl file that I generated a proxy code from.
    My proxy code has just following tags:

    namespace A.Service
    {
        
        [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
        [System.Web.Services.WebServiceBindingAttribute(Name = "SomeSOAPbinding", Namespace = "http://A.Service")]
        public interface IService    {

            /// <remarks/>
            [System.Web.Services.WebMethodAttribute()]
            [System.Web.Services.Protocols.SoapRpcMethodAttribute("", RequestNamespace = "http://A.Service", ResponseNamespace = "http://A.Service")]
            [return: System.Xml.Serialization.SoapElementAttribute("requestMasterListReturn")]
            int requestMasterList();
        }
    }

    This won't work till I add tags     [ServiceContract(Namespace = "http://A.Service")] and [operationContract]

    My question is, why these tags are not getting added to the proxy code while I'm creating it.
    I use the following command to create the proxy code:
    wsdl /si /n:A.Service file.wsdl

    Thanks
    MT

    Thursday, June 4, 2009 9:06 PM

Answers

  • wsdl.exe generates service interfaces (/si option) for ASMX-style (a.k.a. old-style) web services. If you want to use WCF, you need to use svcutil.exe:
        svcutil.exe /t:code /n:*,A.Service file.wsdl

    Notice that this will create not only the service interface, but also a "client" code that can talk to the service. If you just want the service interface (to implement it later) you can discard that part of the code that is used to consume it.

    • Marked as answer by Marco Zhou Monday, June 8, 2009 8:33 AM
    Friday, June 5, 2009 4:36 AM

All replies

  • wsdl.exe generates service interfaces (/si option) for ASMX-style (a.k.a. old-style) web services. If you want to use WCF, you need to use svcutil.exe:
        svcutil.exe /t:code /n:*,A.Service file.wsdl

    Notice that this will create not only the service interface, but also a "client" code that can talk to the service. If you just want the service interface (to implement it later) you can discard that part of the code that is used to consume it.

    • Marked as answer by Marco Zhou Monday, June 8, 2009 8:33 AM
    Friday, June 5, 2009 4:36 AM
  • wsdl.exe is for generating proxy/metadata generation for ASMX (.NET 2.0 XML Web services).

    If your service is built using WCF, svcutil.exe should be used to generate client proxies.


    Vivek Desai MCTS (WCF)
    Friday, June 5, 2009 4:45 AM