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
- ArraySubsetEnumerator.cs
- WebPartVerbsEventArgs.cs
- CompilationAssemblyInstallComponent.cs
- XPathDocument.cs
- SplineKeyFrames.cs
- DataBoundLiteralControl.cs
- PriorityQueue.cs
- codemethodreferenceexpression.cs
- RemotingSurrogateSelector.cs
- RepeatBehaviorConverter.cs
- MsmqVerifier.cs
- EventEntry.cs
- SerializationEventsCache.cs
- PixelShader.cs
- EventPrivateKey.cs
- SystemInformation.cs
- ConfigPathUtility.cs
- HostedTransportConfigurationManager.cs
- SrgsRulesCollection.cs
- PropertyChangedEventArgs.cs
- MetadataAssemblyHelper.cs
- LazyTextWriterCreator.cs
- IPAddress.cs
- StorageEntityContainerMapping.cs
- ListViewEditEventArgs.cs
- CallbackDebugElement.cs
- CollaborationHelperFunctions.cs
- TextFormatterHost.cs
- RegionIterator.cs
- SiteMapNode.cs
- CacheSection.cs
- XPathAncestorQuery.cs
- OleAutBinder.cs
- ThumbAutomationPeer.cs
- EntityDataSourceChangingEventArgs.cs
- ValueType.cs
- PageVisual.cs
- FormsAuthenticationModule.cs
- PersonalizationProvider.cs
- SiteMapNodeItem.cs
- ListBoxItemWrapperAutomationPeer.cs
- DesignColumn.cs
- DataGridViewRowsAddedEventArgs.cs
- ControlBuilder.cs
- OleCmdHelper.cs
- RightsManagementEncryptedStream.cs
- SecurityPermission.cs
- DataGridViewCellParsingEventArgs.cs
- ItemCheckEvent.cs
- ByteStorage.cs
- VisemeEventArgs.cs
- Version.cs
- DeviceContexts.cs
- XmlEntity.cs
- CounterSetInstanceCounterDataSet.cs
- XsdValidatingReader.cs
- HttpAsyncResult.cs
- MarshalDirectiveException.cs
- SiteMapPath.cs
- GridViewEditEventArgs.cs
- RootProjectionNode.cs
- TextTreeInsertUndoUnit.cs
- Base64WriteStateInfo.cs
- ExcludePathInfo.cs
- NullRuntimeConfig.cs
- Image.cs
- Queue.cs
- TimeZone.cs
- TraceEventCache.cs
- OledbConnectionStringbuilder.cs
- ClientSettings.cs
- DrawListViewItemEventArgs.cs
- AddInContractAttribute.cs
- LogicalCallContext.cs
- FontFamilyValueSerializer.cs
- SafeProcessHandle.cs
- CodeGenerator.cs
- HtmlDocument.cs
- Vector3dCollection.cs
- TableStyle.cs
- ServerValidateEventArgs.cs
- PseudoWebRequest.cs
- FixedStringLookup.cs
- CheckBoxAutomationPeer.cs
- CustomValidator.cs
- RpcCryptoContext.cs
- XmlBinaryReader.cs
- ProvideValueServiceProvider.cs
- EntityDataSourceView.cs
- ArgumentOutOfRangeException.cs
- DoubleMinMaxAggregationOperator.cs
- NameTable.cs
- Html32TextWriter.cs
- Menu.cs
- TouchesCapturedWithinProperty.cs
- _SSPIWrapper.cs
- PeerObject.cs
- Rect3DValueSerializer.cs
- ThicknessAnimationUsingKeyFrames.cs
- __Error.cs