Click here to Skip to main content
15,885,877 members
Articles / DevOps / Load Testing

VirtualService for ESB

Rate me:
Please Sign up or sign in to vote.
4.90/5 (32 votes)
19 Feb 2008CPOL37 min read 96.7K   1.2K   98  
This article describes the design, implementation, and usage of VirtualService for the Enterprise Service Bus, using the Microsoft .NET FX 3.5 technology.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
//
using RKiss.ESB;

namespace Host
{
    /// <summary>
    /// 
    /// </summary>
    public class LR
    {
        private LR() { }

        #region DomainLoader_config
        public static string DomainLoader_config = @"
        <configuration>
          <system.diagnostics/>

          <system.serviceModel>
            <services>
                <service name='RKiss.ESB.DomainLoader' behaviorConfiguration='logmessages22'>
                    <endpoint address='net.pipe://localhost/DomainLoader' binding='netNamedPipeBinding' contract='RKiss.ESB.IDomainLoader'/>
                    <endpoint address='net.pipe://localhost/DomainLoader/mex' binding='mexNamedPipeBinding' contract='IMetadataExchange'/>
                    <endpoint address='net.null://localhost/DomainLoader' binding='customBinding' bindingConfiguration='NewBinding5' contract='RKiss.ESB.IDomainLoader'/>
                </service>
            </services>

            <bindings>
                <customBinding>
                  <binding name='NewBinding5'>
                    <context contextExchangeMechanism='ContextSoapHeader' protectionLevel='None'/>
                    <nullTransport />
                  </binding>
                  <binding name='NewBinding20'>
                    <!--context contextExchangeMechanism='ContextSoapHeader' protectionLevel='None'/-->
                    <namedPipeTransport />
                  </binding>
                </customBinding>
            </bindings>

            <behaviors>
                <serviceBehaviors>
                  <behavior name='logmessages22'>
                    <serviceMetadata/>
                    <serviceTimeouts/>
			        <dataContractSerializer/>
			        <serviceThrottling maxConcurrentCalls='6' maxConcurrentInstances='6'/>
                    <logger enable='true' logAfterReceiveRequest='true' logBeforeSendReply='true'/>
                    <serviceCredentials>
                      <windowsAuthentication allowAnonymousLogons='false' includeWindowsGroups='true' />
                    </serviceCredentials>
                    <serviceDebug includeExceptionDetailInFaults='true' /> 
                  </behavior>          
                </serviceBehaviors>
             </behaviors>
          </system.serviceModel>
        </configuration>";
        #endregion

        #region HostTest_config
        public static string HostTest_config = @"
        <configuration>
          <system.diagnostics/>

          <system.serviceModel>
            <services>
                <service name='Host.Test' behaviorConfiguration='logmessages1234'>
                    <!--endpoint address='net.null://localhost/dada2' binding='customBinding' bindingConfiguration='NewBinding55' contract='Contract.ITest' /-->
				    <!--endpoint address='net.null://localhost/test/dada2' binding='customBinding' bindingConfiguration='NewBinding55' contract='Contract.ITest3' /-->
                    <endpoint address='net.pipe://localhost/dada2' binding='netNamedPipeBinding' bindingConfiguration='NewBinding20' contract='Contract.ITest' />
                    <endpoint address='net.pipe://localhost/test/dada2' binding='netNamedPipeBinding' bindingConfiguration='NewBinding20' contract='Contract.ITest3' />
                </service>
            </services>

            <bindings>
                <customBinding>
                  <binding name='NewBinding55'>
                    <context contextExchangeMechanism='ContextSoapHeader' protectionLevel='None'/>
                    <nullTransport/>
                  </binding>
                  <binding name='NewBinding20'>
                    <context contextExchangeMechanism='ContextSoapHeader' protectionLevel='None'/>
                    <namedPipeTransport />
                  </binding>
                </customBinding>
            </bindings>

            <behaviors>
                <serviceBehaviors>
                  <behavior name='logmessages1234'>
                    <serviceMetadata/>
                    <serviceTimeouts/>
			        <dataContractSerializer/>
			        <serviceThrottling maxConcurrentCalls='6' maxConcurrentInstances='6'/>
                    <logger enable='true' logAfterReceiveRequest='true' logBeforeSendReply='true'/>
                    <serviceCredentials>
                      <windowsAuthentication allowAnonymousLogons='false' includeWindowsGroups='true' />
                    </serviceCredentials>
                    <serviceDebug includeExceptionDetailInFaults='true' /> 
                  </behavior>          
                </serviceBehaviors>
             </behaviors>
          </system.serviceModel>
        </configuration>";
        #endregion

        #region Workflow6_config
        public static string Workflow6_config = @"
        <configuration>
          <system.diagnostics/>
       
          <system.serviceModel>
            <services>
                <service name='WorkflowLibrary1.Workflow6' behaviorConfiguration='logmessages2222'>
                    <endpoint address='net.pipe://localhost/gaga2' binding='customBinding' bindingConfiguration='NewBinding2' contract='Contract.IGenericContract' behaviorConfiguration='xpathAddressFilter'/>
				    <endpoint address='net.null://localhost/fafa6'  binding='customBinding' bindingConfiguration='NewBinding5'  contract='Contract.IGenericContract' />
				    <endpoint address='net.pipe://localhost/fafa6/mex' binding='customBinding' bindingConfiguration='NewBinding2' contract='Contract.IGenericContract' />
                </service>
            </services>

	        <client>
			    <endpoint name='Ping' address='net.pipe://localhost/dada2' binding='customBinding' bindingConfiguration='NewBinding2' contract='Contract.ITest' behaviorConfiguration='logmessages2222'/>
			    <endpoint name='dada2' address='net.pipe://localhost/test/dada2' binding='customBinding' bindingConfiguration='NewBinding2' contract='Contract.ITest3' />
		    </client>

            <bindings>
                <customBinding>
                  <binding name='NewBinding5'>
                    <context contextExchangeMechanism='ContextSoapHeader' protectionLevel='None'/>
                    <nullTransport />
                  </binding>
                  <binding name='NewBinding2'>
                    <context contextExchangeMechanism='ContextSoapHeader' protectionLevel='None'/>
                    <namedPipeTransport />
                  </binding>
                  <binding name='NewBinding20'>
                    <namedPipeTransport />
                  </binding>
                </customBinding>
            </bindings>

            <behaviors>
                <endpointBehaviors>
                    <behavior name='logmessages2222'>
                         <logger enable='true' logAfterReceiveRequest='true' logBeforeSendReply='true'/>
                    </behavior>
                    <behavior name='xpathAddressFilter'>
                       <createWorkflow operation='ProcessMessage'/>
                        <!--filter enable='false' xpath=""/s12:Envelope/s12:Header/*[local-name()='Context']/*[local-name()='Property'][@name='topic' and text()='1234567890\abcd\*']"" /-->
                        <filter enable='true' xpath=""/s12:Envelope/s12:Header/wsa10:To[contains(substring-after(., 'net.pipe://localhost/'), 'ga2')]""/>
                    </behavior>
                </endpointBehaviors>
                <serviceBehaviors>
                  <behavior name='logmessages2222'>
                    <!--serviceMetadata/-->
                    <serviceTimeouts/>
			        <dataContractSerializer/>
			        <serviceThrottling maxConcurrentCalls='6' maxConcurrentInstances='6'/>
                    <logger enable='true' logAfterReceiveRequest='true' logBeforeSendReply='true'/>
                    <serviceCredentials>
                      <windowsAuthentication allowAnonymousLogons='false' includeWindowsGroups='true' />
                    </serviceCredentials>
                    <serviceDebug includeExceptionDetailInFaults='true' /> 
                    <workflowRuntime name='WorkflowServiceHostRuntime' validateOnCreate='false' enablePerformanceCounters='true' >
                      <commonParameters>
                        <add name='abcd' value='12345'/>
                      </commonParameters> 
                      <services>
                        <add type='Host.ShowWorklowEvents, Host'/>
                        <add type='System.Workflow.Runtime.Hosting.SqlWorkflowPersistenceService, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
                             connectionString='Data Source=localhost\sqlexpress;Initial Catalog=PersistenceStore;Integrated Security=True;Pooling=False'
                             LoadIntervalSeconds='1' UnLoadOnIdle='true'  />
                        <add type='System.Workflow.Activities.ExternalDataExchangeService, System.Workflow.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'/>
                      </services>              
                    </workflowRuntime>      
                  </behavior>          
                </serviceBehaviors>
             </behaviors>
          </system.serviceModel>
        </configuration>";
        #endregion

        #region Workflow6_wsdl
        public static string Workflow6_wsdl = @"
        <Metadata xmlns:wsx='http://schemas.xmlsoap.org/ws/2004/09/mex' xmlns='http://schemas.xmlsoap.org/ws/2004/09/mex'>
          <wsx:MetadataSection xmlns='' Dialect='http://schemas.xmlsoap.org/wsdl/' Identifier='http://tempuri.org/'>
            <wsdl:definitions xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' 
			    xmlns:wsu='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd' 
			    xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/' 
			    xmlns:wsam='http://www.w3.org/2007/05/addressing/metadata' 
			    xmlns:tns='http://tempuri.org/' 
			    xmlns:wsa='http://schemas.xmlsoap.org/ws/2004/08/addressing' 
			    xmlns:wsp='http://schemas.xmlsoap.org/ws/2004/09/policy' 
			    xmlns:wsap='http://schemas.xmlsoap.org/ws/2004/08/addressing/policy' 
			    xmlns:xsd='http://www.w3.org/2001/XMLSchema' 
			    xmlns:msc='http://schemas.microsoft.com/ws/2005/12/wsdl/contract' 
			    xmlns:wsaw='http://www.w3.org/2006/05/addressing/wsdl' 
			    xmlns:soap12='http://schemas.xmlsoap.org/wsdl/soap12/' 
			    xmlns:wsa10='http://www.w3.org/2005/08/addressing' name='DomainLoader'
			    targetNamespace='http://tempuri.org/' xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'>
              <wsp:Policy wsu:Id='NetNamedPipeBinding_IDomainLoader_policy'>
                <wsp:ExactlyOne>
                  <wsp:All>
                    <msb:BinaryEncoding xmlns:msb='http://schemas.microsoft.com/ws/06/2004/mspolicy/netbinary1' />
                    <sp:TransportBinding xmlns:sp='http://schemas.xmlsoap.org/ws/2005/07/securitypolicy'>
                      <wsp:Policy>
                        <sp:TransportToken>
                          <wsp:Policy>
                            <msf:WindowsTransportSecurity xmlns:msf='http://schemas.microsoft.com/ws/2006/05/framing/policy'>
                              <msf:ProtectionLevel>EncryptAndSign</msf:ProtectionLevel>
                            </msf:WindowsTransportSecurity>
                          </wsp:Policy>
                        </sp:TransportToken>
                        <sp:AlgorithmSuite>
                          <wsp:Policy>
                            <sp:Basic256 />
                          </wsp:Policy>
                        </sp:AlgorithmSuite>
                        <sp:Layout>
                          <wsp:Policy>
                            <sp:Strict />
                          </wsp:Policy>
                        </sp:Layout>
                      </wsp:Policy>
                    </sp:TransportBinding>
                    <wsaw:UsingAddressing />
                  </wsp:All>
                </wsp:ExactlyOne>
              </wsp:Policy>
              <wsp:Policy wsu:Id='CustomBinding_IDomainLoader_policy'>
                <wsp:ExactlyOne>
                  <wsp:All>
                    <IncludeContext ProtectionLevel='None' xmlns='http://schemas.microsoft.com/ws/2006/05/context' />
                  </wsp:All>
                </wsp:ExactlyOne>
              </wsp:Policy>
              <wsdl:types>
                <xsd:schema targetNamespace='http://tempuri.org/Imports'>
                  <xsd:import namespace='http://tempuri.org/' />
                  <xsd:import namespace='http://schemas.microsoft.com/2003/10/Serialization/' />
                  <xsd:import namespace='http://schemas.datacontract.org/2004/07/ESB' />
                </xsd:schema>
              </wsdl:types>
              <wsdl:message name='IDomainLoader_UnloadDomain_InputMessage'>
                <wsdl:part name='parameters' element='tns:UnloadDomain' />
              </wsdl:message>
              <wsdl:message name='IDomainLoader_UnloadDomain_OutputMessage'>
                <wsdl:part name='parameters' element='tns:UnloadDomainResponse' />
              </wsdl:message>
              <wsdl:message name='IDomainLoader_ReloadDomain_InputMessage'>
                <wsdl:part name='parameters' element='tns:ReloadDomain' />
              </wsdl:message>
              <wsdl:message name='IDomainLoader_ReloadDomain_OutputMessage'>
                <wsdl:part name='parameters' element='tns:ReloadDomainResponse' />
              </wsdl:message>
              <wsdl:message name='IDomainLoader_GetHostedServices_InputMessage'>
                <wsdl:part name='parameters' element='tns:GetHostedServices' />
              </wsdl:message>
              <wsdl:message name='IDomainLoader_GetHostedServices_OutputMessage'>
                <wsdl:part name='parameters' element='tns:GetHostedServicesResponse' />
              </wsdl:message>
              <wsdl:portType name='IDomainLoader'>
                <wsdl:operation name='UnloadDomain'>
                  <wsdl:input wsaw:Action='http://tempuri.org/IDomainLoader/UnloadDomain' message='tns:IDomainLoader_UnloadDomain_InputMessage' />
                  <wsdl:output wsaw:Action='http://tempuri.org/IDomainLoader/UnloadDomainResponse' message='tns:IDomainLoader_UnloadDomain_OutputMessage' />
                </wsdl:operation>
                <wsdl:operation name='ReloadDomain'>
                  <wsdl:input wsaw:Action='http://tempuri.org/IDomainLoader/ReloadDomain' message='tns:IDomainLoader_ReloadDomain_InputMessage' />
                  <wsdl:output wsaw:Action='http://tempuri.org/IDomainLoader/ReloadDomainResponse' message='tns:IDomainLoader_ReloadDomain_OutputMessage' />
                </wsdl:operation>
                <wsdl:operation name='GetHostedServices'>
                  <wsdl:input wsaw:Action='http://tempuri.org/IDomainLoader/GetHostedServices' message='tns:IDomainLoader_GetHostedServices_InputMessage' />
                  <wsdl:output wsaw:Action='http://tempuri.org/IDomainLoader/GetHostedServicesResponse' message='tns:IDomainLoader_GetHostedServices_OutputMessage' />
                </wsdl:operation>
              </wsdl:portType>
              <wsdl:binding name='NetNamedPipeBinding_IDomainLoader' type='tns:IDomainLoader'>
                <wsp:PolicyReference URI='#NetNamedPipeBinding_IDomainLoader_policy' />
                <soap12:binding transport='http://schemas.microsoft.com/soap/named-pipe' />
                <wsdl:operation name='UnloadDomain'>
                  <soap12:operation soapAction='http://tempuri.org/IDomainLoader/UnloadDomain' style='document' />
                  <wsdl:input>
                    <soap12:body use='literal' />
                  </wsdl:input>
                  <wsdl:output>
                    <soap12:body use='literal' />
                  </wsdl:output>
                </wsdl:operation>
                <wsdl:operation name='ReloadDomain'>
                  <soap12:operation soapAction='http://tempuri.org/IDomainLoader/ReloadDomain' style='document' />
                  <wsdl:input>
                    <soap12:body use='literal' />
                  </wsdl:input>
                  <wsdl:output>
                    <soap12:body use='literal' />
                  </wsdl:output>
                </wsdl:operation>
                <wsdl:operation name='GetHostedServices'>
                  <soap12:operation soapAction='http://tempuri.org/IDomainLoader/GetHostedServices' style='document' />
                  <wsdl:input>
                    <soap12:body use='literal' />
                  </wsdl:input>
                  <wsdl:output>
                    <soap12:body use='literal' />
                  </wsdl:output>
                </wsdl:operation>
              </wsdl:binding>
              <wsdl:binding name='CustomBinding_IDomainLoader' type='tns:IDomainLoader'>
                <wsp:PolicyReference URI='#CustomBinding_IDomainLoader_policy' />
                <wsdl:operation name='UnloadDomain'>
                  <soap12:operation soapAction='http://tempuri.org/IDomainLoader/UnloadDomain' style='document' />
                  <wsdl:input>
                    <soap12:body use='literal' />
                  </wsdl:input>
                  <wsdl:output>
                    <soap12:body use='literal' />
                  </wsdl:output>
                </wsdl:operation>
                <wsdl:operation name='ReloadDomain'>
                  <soap12:operation soapAction='http://tempuri.org/IDomainLoader/ReloadDomain' style='document' />
                  <wsdl:input>
                    <soap12:body use='literal' />
                  </wsdl:input>
                  <wsdl:output>
                    <soap12:body use='literal' />
                  </wsdl:output>
                </wsdl:operation>
                <wsdl:operation name='GetHostedServices'>
                  <soap12:operation soapAction='http://tempuri.org/IDomainLoader/GetHostedServices' style='document' />
                  <wsdl:input>
                    <soap12:body use='literal' />
                  </wsdl:input>
                  <wsdl:output>
                    <soap12:body use='literal' />
                  </wsdl:output>
                </wsdl:operation>
              </wsdl:binding>
              <wsdl:service name='DomainLoader'>
                <wsdl:port name='NetNamedPipeBinding_IDomainLoader' binding='tns:NetNamedPipeBinding_IDomainLoader'>
                  <soap12:address location='net.pipe://localhost/DomainLoader' />
                  <wsa10:EndpointReference>
                    <wsa10:Address>net.pipe://localhost/DomainLoader</wsa10:Address>
                    <Identity xmlns='http://schemas.xmlsoap.org/ws/2006/02/addressingidentity'>
                      <Upn>RKiss2\RKiss</Upn>
                    </Identity>
                  </wsa10:EndpointReference>
                </wsdl:port>
                <wsdl:port name='CustomBinding_IDomainLoader' binding='tns:CustomBinding_IDomainLoader'>
                  <soap12:address location='net.null://localhost/DomainLoader' />
                </wsdl:port>
              </wsdl:service>
            </wsdl:definitions>
          </wsx:MetadataSection>
          <wsx:MetadataSection xmlns='' Dialect='http://www.w3.org/2001/XMLSchema' Identifier='http://tempuri.org/'>
            <xs:schema xmlns:tns='http://tempuri.org/' elementFormDefault='qualified' targetNamespace='http://tempuri.org/' xmlns:xs='http://www.w3.org/2001/XMLSchema'>
              <xs:import namespace='http://schemas.datacontract.org/2004/07/ESB' />
              <xs:element name='UnloadDomain'>
                <xs:complexType>
                  <xs:sequence>
                    <xs:element minOccurs='0' name='hostName' nillable='true' type='xs:string' />
                    <xs:element minOccurs='0' name='appDomainHostName' nillable='true' type='xs:string' />
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
              <xs:element name='UnloadDomainResponse'>
                <xs:complexType>
                  <xs:sequence />
                </xs:complexType>
              </xs:element>
              <xs:element name='ReloadDomain'>
                <xs:complexType>
                  <xs:sequence>
                    <xs:element minOccurs='0' name='hostName' nillable='true' type='xs:string' />
                    <xs:element minOccurs='0' name='appDomainHostName' nillable='true' type='xs:string' />
                    <xs:element minOccurs='0' name='metadata' nillable='true' xmlns:q1='http://schemas.datacontract.org/2004/07/ESB' type='q1:HostMetadata' />
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
              <xs:element name='ReloadDomainResponse'>
                <xs:complexType>
                  <xs:sequence />
                </xs:complexType>
              </xs:element>
              <xs:element name='GetHostedServices'>
                <xs:complexType>
                  <xs:sequence>
                    <xs:element minOccurs='0' name='hostName' nillable='true' type='xs:string' />
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
              <xs:element name='GetHostedServicesResponse'>
                <xs:complexType>
                  <xs:sequence>
                    <xs:element minOccurs='0' name='GetHostedServicesResult' nillable='true' xmlns:q2='http://schemas.datacontract.org/2004/07/ESB' type='q2:ArrayOfServiceMetadataBase' />
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:schema>
          </wsx:MetadataSection>
          <wsx:MetadataSection xmlns='' Dialect='http://www.w3.org/2001/XMLSchema' Identifier='http://schemas.microsoft.com/2003/10/Serialization/'>
            <xs:schema xmlns:tns='http://schemas.microsoft.com/2003/10/Serialization/' attributeFormDefault='qualified' elementFormDefault='qualified' targetNamespace='http://schemas.microsoft.com/2003/10/Serialization/' xmlns:xs='http://www.w3.org/2001/XMLSchema'>
              <xs:element name='anyType' nillable='true' type='xs:anyType' />
              <xs:element name='anyURI' nillable='true' type='xs:anyURI' />
              <xs:element name='base64Binary' nillable='true' type='xs:base64Binary' />
              <xs:element name='boolean' nillable='true' type='xs:boolean' />
              <xs:element name='byte' nillable='true' type='xs:byte' />
              <xs:element name='dateTime' nillable='true' type='xs:dateTime' />
              <xs:element name='decimal' nillable='true' type='xs:decimal' />
              <xs:element name='double' nillable='true' type='xs:double' />
              <xs:element name='float' nillable='true' type='xs:float' />
              <xs:element name='int' nillable='true' type='xs:int' />
              <xs:element name='long' nillable='true' type='xs:long' />
              <xs:element name='QName' nillable='true' type='xs:QName' />
              <xs:element name='short' nillable='true' type='xs:short' />
              <xs:element name='string' nillable='true' type='xs:string' />
              <xs:element name='unsignedByte' nillable='true' type='xs:unsignedByte' />
              <xs:element name='unsignedInt' nillable='true' type='xs:unsignedInt' />
              <xs:element name='unsignedLong' nillable='true' type='xs:unsignedLong' />
              <xs:element name='unsignedShort' nillable='true' type='xs:unsignedShort' />
              <xs:element name='char' nillable='true' type='tns:char' />
              <xs:simpleType name='char'>
                <xs:restriction base='xs:int' />
              </xs:simpleType>
              <xs:element name='duration' nillable='true' type='tns:duration' />
              <xs:simpleType name='duration'>
                <xs:restriction base='xs:duration'>
                  <xs:pattern value='\-?P(\d*D)?(T(\d*H)?(\d*M)?(\d*(\.\d*)?S)?)?' />
                  <xs:minInclusive value='-P10675199DT2H48M5.4775808S' />
                  <xs:maxInclusive value='P10675199DT2H48M5.4775807S' />
                </xs:restriction>
              </xs:simpleType>
              <xs:element name='guid' nillable='true' type='tns:guid' />
              <xs:simpleType name='guid'>
                <xs:restriction base='xs:string'>
                  <xs:pattern value='[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}' />
                </xs:restriction>
              </xs:simpleType>
              <xs:attribute name='FactoryType' type='xs:QName' />
            </xs:schema>
          </wsx:MetadataSection>
          <wsx:MetadataSection xmlns='' Dialect='http://www.w3.org/2001/XMLSchema' Identifier='http://schemas.datacontract.org/2004/07/ESB'>
            <xs:schema xmlns:tns='http://schemas.datacontract.org/2004/07/ESB' elementFormDefault='qualified' targetNamespace='http://schemas.datacontract.org/2004/07/ESB' xmlns:xs='http://www.w3.org/2001/XMLSchema'>
              <xs:complexType name='HostMetadata'>
                <xs:sequence>
                  <xs:element minOccurs='0' maxOccurs='unbounded' name='ServiceMetadata' nillable='true' type='tns:ServiceMetadata' />
                </xs:sequence>
              </xs:complexType>
              <xs:element name='HostMetadata' nillable='true' type='tns:HostMetadata' />
              <xs:complexType name='ServiceMetadata'>
                <xs:complexContent mixed='false'>
                  <xs:extension base='tns:ServiceMetadataBase'>
                    <xs:sequence>
                      <xs:element minOccurs='0' name='Config' nillable='true' type='xs:string' />
                      <xs:element minOccurs='0' name='Rules' nillable='true' type='xs:string' />
                      <xs:element minOccurs='0' name='Wsdl' nillable='true' type='xs:string' />
                      <xs:element minOccurs='0' name='Xoml' nillable='true' type='xs:string' />
                    </xs:sequence>
                  </xs:extension>
                </xs:complexContent>
              </xs:complexType>
              <xs:element name='ServiceMetadata' nillable='true' type='tns:ServiceMetadata' />
              <xs:complexType name='ServiceMetadataBase'>
                <xs:sequence>
                  <xs:element minOccurs='0' name='AppDomainHostName' nillable='true' type='xs:string' />
                  <xs:element minOccurs='0' name='Name' nillable='true' type='xs:string' />
                  <xs:element minOccurs='0' name='Topic' nillable='true' type='xs:string' />
                </xs:sequence>
              </xs:complexType>
              <xs:element name='ServiceMetadataBase' nillable='true' type='tns:ServiceMetadataBase' />
              <xs:complexType name='ArrayOfServiceMetadataBase'>
                <xs:sequence>
                  <xs:element minOccurs='0' maxOccurs='unbounded' name='ServiceMetadataBase' nillable='true' type='tns:ServiceMetadataBase' />
                </xs:sequence>
              </xs:complexType>
              <xs:element name='ArrayOfServiceMetadataBase' nillable='true' type='tns:ArrayOfServiceMetadataBase' />
            </xs:schema>
          </wsx:MetadataSection>
        </Metadata>";
        #endregion

        #region Workflow6_xslt
        public static string Workflow6_xslt = @"
        <serviceMediators>
            <operations>
                <operation action='http://tempuri.org/ITest/Ping3'>
                    <input> 
                        <mediator name='im1' xpath='/' validation='true'>
                            <xslt>
                                <xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
                                    <xsl:variable name='image-dir'>/images</xsl:variable>
                                    <xsl:template match='photograph'>
                                        <img src='{$image-dir}/{href}' width='{size/@width}'/>
                                    </xsl:template>
                                </xsl:stylesheet>
                            </xslt>
                        </mediator>
                        <mediator name='im2' xpath='/' validation='true' xslt='c:\repository\translator.xsl' /> 
                    </input>
                    <output>
                        <mediator name='om1' xpath='/' validation='true' xslt='c:\repository\translator.xsl'/>
                    </output>
                    <error>
                        <mediator name='em1' xpath='/' validation='true' xslt='c:\repository\translator.xsl'/>
                    </error>      
                </operation>
                <operation action='test2'>  
                    <input> 
                        <mediator name='im11' xpath='/' validation='true'>
                            <xslt>
                                <xsl:stylesheet version='1.0' 
                                    xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
                                    xmlns:ext='urn:function1'
                                    xmlns:x='urn:test'>
                                    <xsl:output method='xml' omit-xml-declaration='yes' />
                                    <xsl:param name='param1'>defaultValue</xsl:param>
                                    <xsl:template match='x:Person'>
		                                <Person >
                                            <Name id='{$param1}'>
                                                <xsl:value-of select='x:FirstName'/>
                                                <xsl:text>/</xsl:text>
                                                <xsl:value-of select='ext:Name(x:FirstName, x:LastName)'/>
                                                <xsl:text>/</xsl:text>
                                                <xsl:value-of select='x:LastName'/>
                                            </Name>
                                        </Person>
	                                </xsl:template>
                                </xsl:stylesheet>
                            </xslt>
                            <params>
                                <param name='param1' namespace='' value='11111' />
                            </params>
                            <functions>
                                <function name='urn:function1' type='RKiss.ESB.XsltExtensionObject, ESB.Core' />
                            </functions>
                        </mediator>                       
                    </input>
                </operation>
                <operation action='http://tempuri.org/ITest3/Ping3'>  
	                <output> 
		                <mediator name='om3' xpath='/' validation='true'>
			              <xslt>
			                <xsl:stylesheet version='1.0' 
				                xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
				                xmlns:a='http://www.w3.org/2005/08/addressing'
				                xmlns:s='http://www.w3.org/2003/05/soap-envelope'>
				                <xsl:output method='xml' omit-xml-declaration='yes' />
				                <xsl:param name='result'>?</xsl:param>
				                <xsl:template match='s:Envelope/s:Body'>
	                                <s:Envelope>
				                      <s:Header>
					                    <a:Action s:mustUnderstand='1'>http://tempuri.org/ITest3/Ping3Response</a:Action>
				                      </s:Header>
				                      <s:Body>
					                    <Ping3Response xmlns='http://tempuri.org/'>
					                      <Ping3Result><xsl:value-of select='$result'/></Ping3Result>
					                    </Ping3Response>
				                      </s:Body>
				                    </s:Envelope>                   
				                </xsl:template>
			                  </xsl:stylesheet>
			                </xslt>
			                <params>
				                <param name='result' namespace='' value='Hello World' />
			                </params>			
		                </mediator>                       
	             </output>
	            </operation>
            </operations>                                         
        </serviceMediators>";
        #endregion

        public static HostMetadata GetMetadata
        {
            get
            {
                // create a local repository
                HostMetadata catalog = new HostMetadata
                {
                    HostName = "Application_Test",
                    AssemblyNames = "Host; WorkflowLibrary1",
                    List = new ServiceMetadataCollection 
                    {
                        new ServiceMetadata{ AppDomainHostName="Business_1", Name="Host.Test", Config=V(HostTest_config)}, 
                        new ServiceMetadata{ AppDomainHostName="Business_1", Name="WorkflowLibrary1.Workflow6", 
                            Config=V(Workflow6_config), 
                            Xoml="",   
                            Rules="", 
                            Wsdl=V(Workflow6_wsdl), 
                            Xslt=V(Workflow6_xslt)},
                        new ServiceMetadata{ Name="RKiss.ESB.DomainLoader", Config=V(DomainLoader_config)}

                        // add more services
                    }                   
                };
                return catalog;
            }
        }

        public static string V(string xmltext)
        {
            System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
            doc.LoadXml(xmltext);
            return doc.OuterXml;
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions