How to generate a WSDL file from a C# webservice

前端 未结 3 1135
一向
一向 2021-02-02 13:21

I\'ve created a WebService like this:

[WebService(Namespace = \"http://ns\")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class GroupMan         


        
相关标签:
3条回答
  • 2021-02-02 13:58

    See svcutil /?

                              -= METADATA EXPORT =-
    
    Description: svcutil.exe can export metadata for services, contracts and data types in compiled assemblies. To
        export metadata for a service, you must use the /serviceName option to indicate the service you would like
        to export. To export all Data Contract types within an assembly use the /dataContractOnly option. By
        default metadata is exported for all Service Contracts in the input assemblies.
    
    Syntax: svcutil.exe [/t:metadata] [/serviceName:<serviceConfigName>] [/dataContractOnly] <assemblyPath>*
    
     <assemblyPath> - The path to an assembly that contains services, contracts or Data Contract types to be
                      exported. Standard command-line wildcards can be used to provide multiple files as input.
    
    Options:
    
     /serviceName:<serviceConfigName> - The config name of a service to export. If this option is used, an
                                        executable assembly with an associated config file must be passed as
                                        input. Svcutil will search through all associated config files for the
                                        service configuration. If the config files contain any extension types,
                                        the assemblies containing these types must either be in the GAC or
                                        explicitly provided using the /r option.
     /reference:<file path>           - Add the specified assembly to the set of assemblies used for resolving
                                        type references. If you are exporting or validating a service that uses
                                        3rd-party extensions (Behaviors, Bindings and BindingElements) registered
                                        in config use this option to locate extension assemblies that are not in
                                        the GAC.  (Short Form: /r)
     /dataContractOnly                - Operate on Data Contract types only. Service Contracts will not be
                                        processed. (Short Form: /dconly)
     /excludeType:<type>              - The fully-qualified or assembly-qualified name of a type to exclude from
                                        export. This option can be used when exporting metadata for a service or a
                                        set of service contracts to exclude types from being exported. This option
                                        cannot be used with the /dconly option. (Short Form: /et)
    
    0 讨论(0)
  • 2021-02-02 14:08

    I've created a tool which can generate a WSDL file from a compiled c# assembly (dll) which contains one or more WebServices. Normally you require a running service (IIS or other) which hosts the .asmx so that you can retrieve the WSDL using /MyWebService.asmx?wsdl

    This tool generate a WSDL file using reflection to retrieve all information from an assembly (dll).

    Download can be found at https://github.com/StefH/WSDLGenerator

    0 讨论(0)
  • 2021-02-02 14:14

    Svcutil.exe will definitely generate the WSDL with the service down. The correct usage is svcutil your.executable.dll(exe). I'm using this a lot so I'm sure it will generate the WSDL.

    0 讨论(0)
提交回复
热议问题