Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Services / Web / System / Web / Services / Description / SoapHttpTransportImporter.cs / 1305376 / SoapHttpTransportImporter.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.Services.Description { using System.CodeDom; using System.Web.Services.Protocols; internal class SoapHttpTransportImporter : SoapTransportImporter { public override bool IsSupportedTransport(string transport) { return transport == SoapBinding.HttpTransport; } public override void ImportClass() { // grab this here so it gets marked "handled" for both client and server SoapAddressBinding soapAddress = ImportContext.Port == null ? null : (SoapAddressBinding)ImportContext.Port.Extensions.Find(typeof(SoapAddressBinding)); if (ImportContext.Style == ServiceDescriptionImportStyle.Client) { ImportContext.CodeTypeDeclaration.BaseTypes.Add(typeof(SoapHttpClientProtocol).FullName); CodeConstructor ctor = WebCodeGenerator.AddConstructor(ImportContext.CodeTypeDeclaration, new string[0], new string[0], null, CodeFlags.IsPublic); ctor.Comments.Add(new CodeCommentStatement(Res.GetString(Res.CodeRemarks), true)); bool soap11 = true; if (ImportContext is Soap12ProtocolImporter) { soap11 = false; // add version code CodeTypeReferenceExpression versionEnumTypeReference = new CodeTypeReferenceExpression(typeof(SoapProtocolVersion)); CodeFieldReferenceExpression versionEnumFieldReference = new CodeFieldReferenceExpression(versionEnumTypeReference, Enum.Format(typeof(SoapProtocolVersion), SoapProtocolVersion.Soap12, "G")); CodePropertyReferenceExpression versionPropertyReference = new CodePropertyReferenceExpression(new CodeThisReferenceExpression(), "SoapVersion"); CodeAssignStatement assignVersionStatement = new CodeAssignStatement(versionPropertyReference, versionEnumFieldReference); ctor.Statements.Add(assignVersionStatement); } ServiceDescription serviceDescription = ImportContext.Binding.ServiceDescription; string url = (soapAddress != null) ? soapAddress.Location : null; string urlKey = serviceDescription.AppSettingUrlKey; string baseUrl = serviceDescription.AppSettingBaseUrl; ProtocolImporterUtil.GenerateConstructorStatements(ctor, url, urlKey, baseUrl, soap11 && !ImportContext.IsEncodedBinding); } else if (ImportContext.Style == ServiceDescriptionImportStyle.Server) { ImportContext.CodeTypeDeclaration.BaseTypes.Add(typeof(WebService).FullName); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.Services.Description { using System.CodeDom; using System.Web.Services.Protocols; internal class SoapHttpTransportImporter : SoapTransportImporter { public override bool IsSupportedTransport(string transport) { return transport == SoapBinding.HttpTransport; } public override void ImportClass() { // grab this here so it gets marked "handled" for both client and server SoapAddressBinding soapAddress = ImportContext.Port == null ? null : (SoapAddressBinding)ImportContext.Port.Extensions.Find(typeof(SoapAddressBinding)); if (ImportContext.Style == ServiceDescriptionImportStyle.Client) { ImportContext.CodeTypeDeclaration.BaseTypes.Add(typeof(SoapHttpClientProtocol).FullName); CodeConstructor ctor = WebCodeGenerator.AddConstructor(ImportContext.CodeTypeDeclaration, new string[0], new string[0], null, CodeFlags.IsPublic); ctor.Comments.Add(new CodeCommentStatement(Res.GetString(Res.CodeRemarks), true)); bool soap11 = true; if (ImportContext is Soap12ProtocolImporter) { soap11 = false; // add version code CodeTypeReferenceExpression versionEnumTypeReference = new CodeTypeReferenceExpression(typeof(SoapProtocolVersion)); CodeFieldReferenceExpression versionEnumFieldReference = new CodeFieldReferenceExpression(versionEnumTypeReference, Enum.Format(typeof(SoapProtocolVersion), SoapProtocolVersion.Soap12, "G")); CodePropertyReferenceExpression versionPropertyReference = new CodePropertyReferenceExpression(new CodeThisReferenceExpression(), "SoapVersion"); CodeAssignStatement assignVersionStatement = new CodeAssignStatement(versionPropertyReference, versionEnumFieldReference); ctor.Statements.Add(assignVersionStatement); } ServiceDescription serviceDescription = ImportContext.Binding.ServiceDescription; string url = (soapAddress != null) ? soapAddress.Location : null; string urlKey = serviceDescription.AppSettingUrlKey; string baseUrl = serviceDescription.AppSettingBaseUrl; ProtocolImporterUtil.GenerateConstructorStatements(ctor, url, urlKey, baseUrl, soap11 && !ImportContext.IsEncodedBinding); } else if (ImportContext.Style == ServiceDescriptionImportStyle.Server) { ImportContext.CodeTypeDeclaration.BaseTypes.Add(typeof(WebService).FullName); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- OleDbConnectionPoolGroupProviderInfo.cs
- HtmlButton.cs
- EntityDataSourceChangedEventArgs.cs
- RelOps.cs
- KoreanCalendar.cs
- ColumnHeaderConverter.cs
- EntitySetBaseCollection.cs
- EmptyQuery.cs
- XmlSchemaInclude.cs
- XmlAttributeOverrides.cs
- PreservationFileReader.cs
- IntellisenseTextBox.cs
- EndpointAddressElementBase.cs
- DrawingContextDrawingContextWalker.cs
- PassportIdentity.cs
- DataGridCellItemAutomationPeer.cs
- PermissionRequestEvidence.cs
- EmptyQuery.cs
- ToolStripItemDesigner.cs
- IHttpResponseInternal.cs
- ReverseInheritProperty.cs
- DropSource.cs
- WindowsTitleBar.cs
- WebPartDescription.cs
- ErrorHandler.cs
- IndexOutOfRangeException.cs
- PageAdapter.cs
- MultiSelectRootGridEntry.cs
- InkCanvasSelection.cs
- EdmRelationshipNavigationPropertyAttribute.cs
- HtmlEmptyTagControlBuilder.cs
- shaperfactoryquerycachekey.cs
- TimerEventSubscription.cs
- CommandBinding.cs
- MinimizableAttributeTypeConverter.cs
- LinqDataSourceUpdateEventArgs.cs
- DesignerTransaction.cs
- ToolStripItemRenderEventArgs.cs
- handlecollector.cs
- Column.cs
- GatewayIPAddressInformationCollection.cs
- XamlReader.cs
- PartManifestEntry.cs
- DebugTrace.cs
- FileRecordSequence.cs
- SqlNodeAnnotation.cs
- ECDiffieHellmanPublicKey.cs
- MulticastNotSupportedException.cs
- WindowsTokenRoleProvider.cs
- DefaultProxySection.cs
- DataReaderContainer.cs
- InstanceLockQueryResult.cs
- ResXFileRef.cs
- NullRuntimeConfig.cs
- ParseChildrenAsPropertiesAttribute.cs
- StateRuntime.cs
- BaseDataListDesigner.cs
- SqlMultiplexer.cs
- ResXDataNode.cs
- PixelFormatConverter.cs
- EntityDataSourceChangingEventArgs.cs
- ResXResourceSet.cs
- HtmlEmptyTagControlBuilder.cs
- PKCS1MaskGenerationMethod.cs
- TableStyle.cs
- DropShadowBitmapEffect.cs
- BitmapDecoder.cs
- InkCanvasSelection.cs
- TextRangeAdaptor.cs
- CriticalHandle.cs
- BulletedListDesigner.cs
- HuffmanTree.cs
- RTLAwareMessageBox.cs
- TdsParserSessionPool.cs
- DuplicateDetector.cs
- ProfileGroupSettingsCollection.cs
- VideoDrawing.cs
- CursorConverter.cs
- FillErrorEventArgs.cs
- SymmetricSecurityProtocol.cs
- HostExecutionContextManager.cs
- SwitchLevelAttribute.cs
- XPathPatternParser.cs
- ProxyWebPartManager.cs
- RegexReplacement.cs
- UnSafeCharBuffer.cs
- DataSourceHelper.cs
- xsdvalidator.cs
- PropertyPathConverter.cs
- State.cs
- ToolStripSeparatorRenderEventArgs.cs
- RedirectionProxy.cs
- ExceptionRoutedEventArgs.cs
- Int16AnimationUsingKeyFrames.cs
- ValidateNames.cs
- ResXFileRef.cs
- SimpleParser.cs
- BuildProvider.cs
- ExtendLockCommand.cs
- BaseValidator.cs