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
- ExceptionValidationRule.cs
- Canvas.cs
- SmiEventSink_Default.cs
- ThaiBuddhistCalendar.cs
- SourceFileBuildProvider.cs
- HtmlInputHidden.cs
- RegexGroup.cs
- ReflectionUtil.cs
- TcpHostedTransportConfiguration.cs
- Context.cs
- DynamicControlParameter.cs
- ProfessionalColorTable.cs
- MatrixAnimationBase.cs
- filewebresponse.cs
- AttributeEmitter.cs
- SqlStatistics.cs
- MailAddressCollection.cs
- ConvertEvent.cs
- DecimalConverter.cs
- LogEntrySerialization.cs
- PeerService.cs
- JavascriptXmlWriterWrapper.cs
- RelationshipEnd.cs
- MenuItemBinding.cs
- XsltOutput.cs
- GridViewDeletedEventArgs.cs
- GenericTypeParameterBuilder.cs
- UInt16Storage.cs
- FixedTextContainer.cs
- PreviewPrintController.cs
- ReadOnlyCollectionBase.cs
- BrowserCapabilitiesFactoryBase.cs
- OperationAbortedException.cs
- MenuItemStyleCollection.cs
- CompilerGeneratedAttribute.cs
- StaticSiteMapProvider.cs
- StringFormat.cs
- OleStrCAMarshaler.cs
- Exceptions.cs
- LineMetrics.cs
- dataSvcMapFileLoader.cs
- DrawingContextWalker.cs
- SyndicationSerializer.cs
- TypedElement.cs
- SlotInfo.cs
- WindowsToolbarItemAsMenuItem.cs
- LongSumAggregationOperator.cs
- NullEntityWrapper.cs
- TdsRecordBufferSetter.cs
- TextDecorationUnitValidation.cs
- ClientConvert.cs
- StringToken.cs
- HashHelper.cs
- CapabilitiesRule.cs
- FixedSOMContainer.cs
- DocumentPaginator.cs
- XhtmlBasicListAdapter.cs
- XmlWriterTraceListener.cs
- AttachmentCollection.cs
- StateWorkerRequest.cs
- ResourceReferenceKeyNotFoundException.cs
- XmlSiteMapProvider.cs
- ExpressionBuilderContext.cs
- AutomationElementIdentifiers.cs
- StringWriter.cs
- CodeTypeConstructor.cs
- XComponentModel.cs
- Util.cs
- RuleSettingsCollection.cs
- QilName.cs
- LinqDataSourceDisposeEventArgs.cs
- MouseOverProperty.cs
- PassportAuthenticationModule.cs
- ServiceRoute.cs
- MasterPageBuildProvider.cs
- CommandHelpers.cs
- IsolatedStorageFile.cs
- InternalPermissions.cs
- ToolBarOverflowPanel.cs
- CaseInsensitiveHashCodeProvider.cs
- SourceItem.cs
- UpdatePanelTrigger.cs
- HtmlWindow.cs
- StorageModelBuildProvider.cs
- LicenseException.cs
- TargetConverter.cs
- BitmapImage.cs
- ListControlConvertEventArgs.cs
- DesignerActionUI.cs
- XamlPointCollectionSerializer.cs
- ApplicationManager.cs
- DataControlButton.cs
- MaxSessionCountExceededException.cs
- TimelineCollection.cs
- EllipticalNodeOperations.cs
- SoundPlayerAction.cs
- SemanticAnalyzer.cs
- SourceChangedEventArgs.cs
- SchemaCreator.cs
- ActivityDesigner.cs