using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel.Description;
using System.Collections.ObjectModel;
using System.ServiceModel.Channels;
using System.Xml;
namespace MyNamespace
{
/// <summary>
/// This class is used to import the address of the port defined for using of JMS.
/// </summary>
public class JmsWsdlImporter : IWsdlImportExtension
{
#region IWsdlImportExtension Members
private string m_DestinationStyle;
public string DestinationStyle
{
get { return m_DestinationStyle; }
}
private string m_InitialContextFactory;
public string InitialContextFactory
{
get { return m_InitialContextFactory; }
}
private string m_JndiConnectionFactoryName;
public string JndiConnectionFactoryName
{
get { return m_JndiConnectionFactoryName; }
}
private string m_JndiDestinationName;
public string JndiDestinationName
{
get { return m_JndiDestinationName; }
}
private string m_JndiProviderURL;
public string JndiProviderURL
{
get { return m_JndiProviderURL; }
}
/// <summary>
/// Not used
/// </summary>
/// <param name="wsdlDocuments"></param>
/// <param name="xmlSchemas"></param>
/// <param name="policy"></param>
public void BeforeImport(System.Web.Services.Description.ServiceDescriptionCollection wsdlDocuments,
System.Xml.Schema.XmlSchemaSet xmlSchemas, ICollection<System.Xml.XmlElement> policy)
{
return;
}
/// <summary>
/// Not used
/// </summary>
/// <param name="importer"></param>
/// <param name="context"></param>
public void ImportContract(WsdlImporter importer, WsdlContractConversionContext context)
{
return;
}
public void ImportEndpoint(WsdlImporter importer, WsdlEndpointConversionContext context)
{
if (context.WsdlPort != null)
{
XmlElement node = context.WsdlPort.Extensions.Find("address", http://schemas.xmlsoap.org/wsdl/jms/);
if (node != null)
{
foreach (XmlAttribute attr in node.Attributes)
{
// Example in the Port definition in the WSDL
/*
<port name="jmsPort" binding="port_type:My_jmsSoap">
<jms:address destinationStyle='topic' initialContextFactory='fr.dyade.aaa.jndi2.client.NamingContextFactory'
jndiConnectionFactoryName="JBITopicConnectionFactory" jndiDestinationName="AddOrderTopic"
jndiProviderURL="scn://host:16400" />
</port>
*/
switch (attr.LocalName.ToLower())
{
case "destinationstyle":
this.m_DestinationStyle = attr.Value;
break;
case "initialcontextfactory":
this.m_InitialContextFactory = attr.Value;
break;
case "jndiconnectionfactoryname":
this.m_JndiConnectionFactoryName = attr.Value;
break;
case "jndidestinationname":
this.m_JndiDestinationName = attr.Value;
break;
case "jndiproviderurl":
this.m_JndiProviderURL = attr.Value;
break;
}
context.Endpoint.Address = new System.ServiceModel.EndpointAddress(http://a);
}
// This ensures that no warning is generated after importing of metadata.
// Please note that import process with all installed extensions has to
// remove all read policies. All not recognized policies will be served as an error
// which is stored in the WsdlImporter.Errors property.
context.WsdlPort.Extensions.Remove(node);
}
}
}
#endregion
}
}