- dynamicwcffactory.zip
- DynamicWCFFactory
- DynamicWCFFactory.gpState
- DynamicWCFFactory.sln
- DynamicWCFFactory.vsmdi
- DynamicWCFFactory
- DynamicWCFFactoryTests
- LocalTestRun.testrunconfig
- TestResults
- UDDIServiceFactory
- WcfService
|
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Net;
using DynamicWCFFactoryTests.ServiceReference;
using System.ServiceModel.Description;
using System.ServiceModel;
using UDDIServiceFactory;
using DynamicWCFFactory;
using Microsoft.Practices.EnterpriseLibrary.Logging;
using System.Configuration;
namespace DynamicWCFFactoryTests
{
/// <summary>
/// Summary description for DynamicWCFFactory
/// </summary>
[TestClass]
public class DynamicWCFFactoryTest
{
#region constants
const int ERROR_SERVICE_CALL = 1000;
const int ERROR_UDDI_FACTORY_CREATION = 1001;
#endregion
public DynamicWCFFactoryTest()
{
if (ConfigurationManager.AppSettings["DisableProxy"] == "1")
WebRequest.DefaultWebProxy = null;
}
private TestContext testContextInstance;
/// <summary>
///Gets or sets the test context which provides
///information about and functionality for the current test run.
///</summary>
public TestContext TestContext
{
get
{
return testContextInstance;
}
set
{
testContextInstance = value;
}
}
#region Additional test attributes
//
// You can use the following additional attributes as you write your tests:
//
// Use ClassInitialize to run code before running the first test in the class
// [ClassInitialize()]
// public static void MyClassInitialize(TestContext testContext) { }
//
// Use ClassCleanup to run code after all tests in a class have run
// [ClassCleanup()]
// public static void MyClassCleanup() { }
//
// Use TestInitialize to run code before running each test
// [TestInitialize()]
// public void MyTestInitialize() { }
//
// Use TestCleanup to run code after each test has run
// [TestCleanup()]
// public void MyTestCleanup() { }
//
#endregion
[TestMethod]
public void TestDynamicWCFFactory()
{
var dynWCFFactory = new DynamicWCFFactory.DynamicWCFFactory<ServiceReference.Service1Client,ServiceReference.IService1>();
ServiceReference.Service1Client client = dynWCFFactory.CreateProxyFromWSDL("http://localhost:4873/Service1.svc");
string someString = client.GetData(2);
}
[TestMethod]
public void TestUDDIFactory()
{
try
{
UDDIServiceFactory<ServiceReference.Service1Client, ServiceReference.IService1> uDDIFactory = new UDDIServiceFactory<ServiceReference.Service1Client, ServiceReference.IService1>("UDDIURL","serviceKey","bindingKey");
ServiceReference.Service1Client client = uDDIFactory.GetFirstProxy();
string someString;
while (true)
{
try
{
someString = client.GetData(2);
client.Close();
break;
}
catch (Exception ex)
{
// Free Ressources as we are going to create a new proxy
if (client.State == CommunicationState.Faulted)
client.Abort();
else if (client.State == CommunicationState.Opened)
client.Close();
if ((ConfigurationManager.GetSection("loggingConfiguration") != null) && (Logger.IsLoggingEnabled()))
Logger.Write(ex, new List<string> { "General" }, 1, ERROR_SERVICE_CALL, System.Diagnostics.TraceEventType.Warning, "Service Call failed.");
client = uDDIFactory.GetNextProxy();
}
}
}
catch (Exception ex)
{
if ((ConfigurationManager.GetSection("loggingConfiguration") != null) && (Logger.IsLoggingEnabled()))
Logger.Write(ex, new List<string> { "General" }, 1, ERROR_UDDI_FACTORY_CREATION, System.Diagnostics.TraceEventType.Warning, "Creation of UDDIServiceFactory failed.");
throw;
}
}
}
}
|
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.
being IT-Engineer since 1995 I am freelancing since then. From networks to programming, from system administration to DBA, from AIX to Windows I offer a wide range of IT-Skill's without considering me the ultimate expert in each area.
I try to avoid complexity wherever I can and so my philosophy is to strictly follow KISS principles.