示例#1
0
        void IWsdlExportExtension.ExportEndpoint(WsdlExporter exporter, WsdlEndpointConversionContext context)
        {
            var extension = new System.Web.Services.Description.SoapBinding {
                Transport = "http://schemas.xmlsoap.org/soap/http",
                Style     = System.Web.Services.Description.SoapBindingStyle.Document
            };

            context.WsdlBinding.Extensions.Add(extension);
            var binding2 = new System.Web.Services.Description.SoapAddressBinding {
                Location = context.Endpoint.Address.Uri.AbsoluteUri
            };

            context.WsdlPort.Extensions.Add(binding2);
        }
 protected override CodeTypeDeclaration BeginClass()
 {
     base.MethodNames.Clear();
     this.soapBinding = (System.Web.Services.Description.SoapBinding) base.Binding.Extensions.Find(typeof(System.Web.Services.Description.SoapBinding));
     this.transport = this.GetTransport(this.soapBinding.Transport);
     Type[] types = new Type[] { typeof(SoapDocumentMethodAttribute), typeof(XmlAttributeAttribute), typeof(WebService), typeof(object), typeof(DebuggerStepThroughAttribute), typeof(DesignerCategoryAttribute) };
     WebCodeGenerator.AddImports(base.CodeNamespace, WebCodeGenerator.GetNamespacesForTypes(types));
     CodeFlags isAbstract = (CodeFlags) 0;
     if (base.Style == ServiceDescriptionImportStyle.Server)
     {
         isAbstract = CodeFlags.IsAbstract;
     }
     else if (base.Style == ServiceDescriptionImportStyle.ServerInterface)
     {
         isAbstract = CodeFlags.IsInterface;
     }
     CodeTypeDeclaration declaration = WebCodeGenerator.CreateClass(base.ClassName, null, new string[0], null, CodeFlags.IsPublic | isAbstract, base.ServiceImporter.CodeGenerator.Supports(GeneratorSupport.PartialTypes));
     declaration.Comments.Add(new CodeCommentStatement(System.Web.Services.Res.GetString("CodeRemarks"), true));
     if (base.Style == ServiceDescriptionImportStyle.Client)
     {
         declaration.CustomAttributes.Add(new CodeAttributeDeclaration(typeof(DebuggerStepThroughAttribute).FullName));
         declaration.CustomAttributes.Add(new CodeAttributeDeclaration(typeof(DesignerCategoryAttribute).FullName, new CodeAttributeArgument[] { new CodeAttributeArgument(new CodePrimitiveExpression("code")) }));
     }
     else if (base.Style == ServiceDescriptionImportStyle.Server)
     {
         CodeAttributeDeclaration declaration2 = new CodeAttributeDeclaration(typeof(WebServiceAttribute).FullName);
         string str = (base.Service != null) ? base.Service.ServiceDescription.TargetNamespace : base.Binding.ServiceDescription.TargetNamespace;
         declaration2.Arguments.Add(new CodeAttributeArgument("Namespace", new CodePrimitiveExpression(str)));
         declaration.CustomAttributes.Add(declaration2);
     }
     CodeAttributeDeclaration declaration3 = new CodeAttributeDeclaration(typeof(WebServiceBindingAttribute).FullName);
     declaration3.Arguments.Add(new CodeAttributeArgument("Name", new CodePrimitiveExpression(XmlConvert.DecodeName(base.Binding.Name))));
     declaration3.Arguments.Add(new CodeAttributeArgument("Namespace", new CodePrimitiveExpression(base.Binding.ServiceDescription.TargetNamespace)));
     declaration.CustomAttributes.Add(declaration3);
     this.codeClasses.Add(declaration);
     this.classHeaders.Clear();
     return declaration;
 }
 protected override void EndClass()
 {
     if (this.transport != null)
     {
         this.transport.ImportClass();
     }
     this.soapBinding = null;
 }