當前位置: 首頁>>代碼示例>>C#>>正文


C# EndpointAddress.WriteTo方法代碼示例

本文整理匯總了C#中System.ServiceModel.EndpointAddress.WriteTo方法的典型用法代碼示例。如果您正苦於以下問題:C# EndpointAddress.WriteTo方法的具體用法?C# EndpointAddress.WriteTo怎麽用?C# EndpointAddress.WriteTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.ServiceModel.EndpointAddress的用法示例。


在下文中一共展示了EndpointAddress.WriteTo方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: AddAddressToWsdlPort

            internal static void AddAddressToWsdlPort(WsdlNS.Port wsdlPort, EndpointAddress addr, AddressingVersion addressing)
            {
                if (addressing == AddressingVersion.None)
                {
                    return;
                }

                MemoryStream stream = new MemoryStream();
                XmlWriter xw = XmlWriter.Create(stream);
                xw.WriteStartElement("temp");

                if (addressing == AddressingVersion.WSAddressing10)
                {
                    xw.WriteAttributeString("xmlns", MetadataStrings.Addressing10.Prefix, null, MetadataStrings.Addressing10.NamespaceUri);
                }
                else if (addressing == AddressingVersion.WSAddressingAugust2004)
                {
                    xw.WriteAttributeString("xmlns", MetadataStrings.Addressing200408.Prefix, null, MetadataStrings.Addressing200408.NamespaceUri);
                }
                else
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                        new InvalidOperationException(SR.GetString(SR.AddressingVersionNotSupported, addressing)));
                }

                addr.WriteTo(addressing, xw);
                xw.WriteEndElement();

                xw.Flush();
                stream.Seek(0, SeekOrigin.Begin);

                XmlReader xr = XmlReader.Create(stream);
                xr.MoveToContent();
                XmlElement endpointRef = (XmlElement)XmlDoc.ReadNode(xr).ChildNodes[0];

                wsdlPort.Extensions.Add(endpointRef);
            }
開發者ID:iskiselev,項目名稱:JSIL.NetFramework,代碼行數:37,代碼來源:WsdlExporter.cs

示例2: SerializeAndSign

        /// <summary>
        /// Sign this information card and write it to a file.
        /// </summary>
        /// <param name="filename">Path to where this card should be stored.</param>
        /// <param name="cert">Certificate to use for signing this card.</param>
        public void SerializeAndSign( string filename, X509Certificate2 cert )
        {
            MemoryStream stream = new MemoryStream();
            XmlWriter writer = XmlWriter.Create( stream );

            writer.WriteStartElement( XmlNames.WSIdentity.InfoCardElement, XmlNames.WSIdentity.Namespace );

            //
            // write the InformationCardReference element
            //
            writer.WriteAttributeString( XmlNames.Xml.Language, XmlNames.Xml.Namespace, m_language );
            writer.WriteStartElement( XmlNames.WSIdentity.InfoCardRefElement, XmlNames.WSIdentity.Namespace );
            writer.WriteElementString( XmlNames.WSIdentity.CardIdElement, XmlNames.WSIdentity.Namespace, m_cardId );
            writer.WriteElementString( XmlNames.WSIdentity.CardVersionElement, XmlNames.WSIdentity.Namespace, m_cardVersion );
            writer.WriteEndElement();

            //
            // card name
            //
            if( !String.IsNullOrEmpty( m_cardName ) )
            {
                writer.WriteStartElement( XmlNames.WSIdentity.CardNameElement, XmlNames.WSIdentity.Namespace );
                writer.WriteString( m_cardName );
                writer.WriteEndElement();
            }

            //
            // card image
            //
            if( null != m_logo && 0 != m_logo.Length )
            {
                writer.WriteStartElement( XmlNames.WSIdentity.CardImageElement, XmlNames.WSIdentity.Namespace );
                if( !String.IsNullOrEmpty( m_mimeType ) )
                {
                    writer.WriteAttributeString( XmlNames.WSIdentity.MimeTypeAttribute, m_mimeType );
                }
                string val = Convert.ToBase64String( m_logo );
                writer.WriteString( val );
                writer.WriteEndElement();
            }

            //
            // card issuer uri
            //
            writer.WriteStartElement( XmlNames.WSIdentity.IssuerElement, XmlNames.WSIdentity.Namespace );
            writer.WriteString( m_issuerId );
            writer.WriteEndElement();

            //
            // issue time
            //
            writer.WriteStartElement( XmlNames.WSIdentity.TimeIssuedElement, XmlNames.WSIdentity.Namespace );
            writer.WriteString( XmlConvert.ToString( m_issuedOn, XmlDateTimeSerializationMode.Utc ) );
            writer.WriteEndElement();

            //
            // expiry time
            //
            writer.WriteStartElement( XmlNames.WSIdentity.TimeExpiresElement, XmlNames.WSIdentity.Namespace );
            writer.WriteString( XmlConvert.ToString( m_expiresOn, XmlDateTimeSerializationMode.Utc ) );
            writer.WriteEndElement();

            //
            // Start the tokenservice list
            //
            writer.WriteStartElement( XmlNames.WSIdentity.TokenServiceListElement, XmlNames.WSIdentity.Namespace );

            EndpointAddressBuilder eprBuilder = new EndpointAddressBuilder();

            eprBuilder.Uri = new Uri( m_issuerId );

            eprBuilder.Identity = new X509CertificateEndpointIdentity( cert );

            if( null != m_mexUri )
            {

                MetadataReference mexRef = new MetadataReference();
                mexRef.Address = new EndpointAddress( m_mexUri );
                mexRef.AddressVersion = AddressingVersion.WSAddressing10;

                MetadataSection mexSection = new MetadataSection();
                mexSection.Metadata = mexRef;

                MetadataSet mexSet = new MetadataSet();
                mexSet.MetadataSections.Add( mexSection );

                MemoryStream memStream = new MemoryStream();

                XmlTextWriter writer1 = new XmlTextWriter( memStream, System.Text.Encoding.UTF8 );

                mexSet.WriteTo( writer1 );

                writer1.Flush();

                memStream.Seek( 0, SeekOrigin.Begin );
//.........這裏部分代碼省略.........
開發者ID:hernandazevedo,項目名稱:JMRTD,代碼行數:101,代碼來源:ManagedInformationCard.cs

示例3: WriteToAddressingNone

		public void WriteToAddressingNone ()
		{
			EndpointAddress a = new EndpointAddress ("http://localhost:8080");
			StringWriter sw = new StringWriter ();
			XmlWriterSettings xws = new XmlWriterSettings ();
			xws.OmitXmlDeclaration = true;
			// #1
			using (XmlDictionaryWriter xw = XmlDictionaryWriter.CreateDictionaryWriter (XmlWriter.Create (sw, xws))) {
				a.WriteTo (AddressingVersion.None, xw, "From", "http://www.w3.org/2005/08/addressing");
			}
			Assert.AreEqual ("<From xmlns=\"http://www.w3.org/2005/08/addressing\">http://localhost:8080/</From>", sw.ToString (), "#1");

			// #2
			sw = new StringWriter ();
			using (XmlDictionaryWriter xw = XmlDictionaryWriter.CreateDictionaryWriter (XmlWriter.Create (sw, xws))) {
				a.WriteTo (AddressingVersion.None, xw);
			}
			Assert.AreEqual ("<EndpointReference xmlns=\"http://schemas.microsoft.com/ws/2005/05/addressing/none\">http://localhost:8080/</EndpointReference>", sw.ToString (), "#2");
		}
開發者ID:nickchal,項目名稱:pash,代碼行數:19,代碼來源:EndpointAddressTest.cs

示例4: WriteToWSA10

		public void WriteToWSA10 ()
		{
			X509Certificate2 cert = new X509Certificate2 ("Test/Resources/test.cer");
			EndpointAddress a = new EndpointAddress (
				new Uri ("http://localhost:8080"),
				new X509CertificateEndpointIdentity (cert));
			StringWriter sw = new StringWriter ();
			XmlWriterSettings xws = new XmlWriterSettings ();
			xws.OmitXmlDeclaration = true;
			using (XmlDictionaryWriter xw = XmlDictionaryWriter.CreateDictionaryWriter (XmlWriter.Create (sw, xws))) {
				a.WriteTo (AddressingVersion.WSAddressing10, xw);
			}
			Assert.AreEqual (C14N ("<EndpointReference xmlns=\"http://www.w3.org/2005/08/addressing\"><Address>http://localhost:8080/</Address>" + identity1 + "</EndpointReference>"), C14N (sw.ToString ()), "#2");
		}
開發者ID:nickchal,項目名稱:pash,代碼行數:14,代碼來源:EndpointAddressTest.cs

示例5: AddAddressToWsdlPort

 internal static void AddAddressToWsdlPort(Port wsdlPort, EndpointAddress addr, AddressingVersion addressing)
 {
     if (addressing != AddressingVersion.None)
     {
         MemoryStream output = new MemoryStream();
         XmlWriter writer = XmlWriter.Create(output);
         writer.WriteStartElement("temp");
         if (addressing == AddressingVersion.WSAddressing10)
         {
             writer.WriteAttributeString("xmlns", "wsa10", null, "http://www.w3.org/2005/08/addressing");
         }
         else
         {
             if (addressing != AddressingVersion.WSAddressingAugust2004)
             {
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("AddressingVersionNotSupported", new object[] { addressing })));
             }
             writer.WriteAttributeString("xmlns", "wsa", null, "http://schemas.xmlsoap.org/ws/2004/08/addressing");
         }
         addr.WriteTo(addressing, writer);
         writer.WriteEndElement();
         writer.Flush();
         output.Seek(0L, SeekOrigin.Begin);
         XmlReader reader = XmlReader.Create(output);
         reader.MoveToContent();
         XmlElement extension = (XmlElement) WsdlExporter.XmlDoc.ReadNode(reader).ChildNodes[0];
         wsdlPort.Extensions.Add(extension);
     }
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:29,代碼來源:WsdlExporter.cs


注:本文中的System.ServiceModel.EndpointAddress.WriteTo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。