WCF integration update (Added Oran Dennison's approach) [SPRNET-317]

This commit is contained in:
bbaia
2008-08-05 00:22:59 +00:00
parent 3c2e420a70
commit d3d15f0a53
16 changed files with 786 additions and 289 deletions

View File

@@ -1,12 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/>
@@ -33,12 +28,12 @@
xmlns:aop="http://www.springframework.net/aop">
<!-- Service definition -->
<object id="calculator"
<object id="calculator" singleton="false"
type="Spring.WcfQuickStart.CalculatorService, Spring.WcfQuickStart.ServerApp">
<property name="SleepInSeconds" value="1"/>
</object>
<object type="Spring.ServiceModel.ServiceExporter, Spring.Services">
<object id="calculatorServiceHost" type="Spring.ServiceModel.Activation.ServiceHostFactoryObject, Spring.Services">
<property name="TargetName" value="calculator" />
</object>
@@ -57,20 +52,7 @@
</objects>
</spring>
<common>
<logging>
<!--
You may use http://www.microsoft.com/technet/sysinternals/Miscellaneous/DebugView.mspx
for viewing TraceLogger output
-->
<factoryAdapter type="Common.Logging.Simple.TraceLoggerFactoryAdapter, Common.Logging">
<arg key="Level" value="ALL" />
<!-- Possible values are ALL, DEBUG, INFO, WARN, ERROR, FATAL, OFF -->
</factoryAdapter>
</logging>
</common>
<system.serviceModel>
<services>

View File

@@ -1,13 +1,14 @@
using System;
using System.Threading;
//using System.ServiceModel;
namespace Spring.WcfQuickStart
{
//[ServiceBehavior(InstanceContextMode=InstanceContextMode.Single)]
public class CalculatorService : ICalculator
{
private int sleepInSeconds;
public int SleepInSeconds
{
get { return sleepInSeconds; }

View File

@@ -42,8 +42,8 @@ namespace Spring.WcfQuickStart
Console.Out.WriteLine("--- Press <return> to quit ---");
Console.ReadLine();
// Programmatically (You need to comment 'ServiceExporter' object definition in App.config)
//using (ServiceHost serviceHost = new ServiceHost("calculator"))
// Programmatically (You need to comment 'calculatorServiceHost' object definition in App.config)
//using (SpringServiceHost serviceHost = new SpringServiceHost("calculator"))
//{
// serviceHost.Open();

View File

@@ -1,21 +1,14 @@
using System;
using System.Reflection;
using AopAlliance.Intercept;
using Common.Logging;
namespace Spring.WcfQuickStart
{
public class SimplePerformanceInterceptor : IMethodInterceptor
{
#region Logging Definition
private readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
#endregion
private string prefix = "Invocation took";
public string Prefix
{
get { return prefix; }
@@ -34,9 +27,8 @@ namespace Spring.WcfQuickStart
finally
{
DateTime stop = DateTime.Now;
TimeSpan time = stop - start;
log.Info(Prefix + " " + time);
Console.Out.WriteLine(Prefix + " " + time);
}
}

View File

@@ -49,10 +49,6 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Common.Logging, Version=1.0.2.0, Culture=neutral, PublicKeyToken=af08829b84f0328e">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\lib\Net\2.0\Common.Logging.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>

View File

@@ -1,29 +1,32 @@
using System;
public class CalculatorService : ICalculator
namespace Spring.WcfQuickStart
{
public double Add(double n1, double n2)
public class CalculatorService : ICalculator
{
return n1 + n2;
}
public double Add(double n1, double n2)
{
return n1 + n2;
}
public double Subtract(double n1, double n2)
{
return n1 - n2;
}
public double Subtract(double n1, double n2)
{
return n1 - n2;
}
public double Multiply(double n1, double n2)
{
return n1 * n2;
}
public double Multiply(double n1, double n2)
{
return n1 * n2;
}
public double Divide(double n1, double n2)
{
return n1 / n2;
}
public double Divide(double n1, double n2)
{
return n1 / n2;
}
public string GetName()
{
return "Web Calculator";
public string GetName()
{
return "Web Calculator";
}
}
}

View File

@@ -1,17 +1,20 @@
using System;
using System.ServiceModel;
[ServiceContract(Namespace = "http://Spring.WcfQuickStart")]
public interface ICalculator
namespace Spring.WcfQuickStart
{
[OperationContract]
double Add(double n1, double n2);
[OperationContract]
double Subtract(double n1, double n2);
[OperationContract]
double Multiply(double n1, double n2);
[OperationContract]
double Divide(double n1, double n2);
[OperationContract]
string GetName();
[ServiceContract(Namespace = "http://Spring.WcfQuickStart")]
public interface ICalculator
{
[OperationContract]
double Add(double n1, double n2);
[OperationContract]
double Subtract(double n1, double n2);
[OperationContract]
double Multiply(double n1, double n2);
[OperationContract]
double Divide(double n1, double n2);
[OperationContract]
string GetName();
}
}

View File

@@ -1 +1 @@
<%@ ServiceHost Language="C#" Debug="true" Service="calculator" Factory="Spring.ServiceModel.Activation.ServiceHostFactory" %>
<%@ ServiceHost Language="C#" Debug="true" Service="Spring.WcfQuickStart.CalculatorService" Factory="Spring.ServiceModel.Activation.ServiceHostFactory" %>

View File

@@ -27,13 +27,13 @@
</context>
<objects xmlns="http://www.springframework.net">
<!-- Service definition -->
<object id="calculator" type="CalculatorService, App_Code"/>
<object id="calculator" type="Spring.WcfQuickStart.CalculatorService, App_Code" singleton="false"/>
</objects>
</spring>
<system.serviceModel>
<services>
<service name="calculator" behaviorConfiguration="DefaultBehavior">
<endpoint address="" binding="basicHttpBinding" contract="ICalculator"/>
<service name="Spring.WcfQuickStart.CalculatorService" behaviorConfiguration="DefaultBehavior">
<endpoint address="" binding="basicHttpBinding" contract="Spring.WcfQuickStart.ICalculator"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>