Changeset 170


Ignore:
Timestamp:
Feb 3, 2013, 9:12:25 AM (11 years ago)
Author:
roman
Message:

Server and Client are converted to REST

Location:
trunk/Utilities/Miscellaneous/WcfRest01
Files:
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Utilities/Miscellaneous/WcfRest01/Client/Client.csproj

    r169 r170  
    1212    <AssemblyName>Client</AssemblyName>
    1313    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
    14     <TargetFrameworkProfile>Client</TargetFrameworkProfile>
     14    <TargetFrameworkProfile>
     15    </TargetFrameworkProfile>
    1516    <FileAlignment>512</FileAlignment>
    1617  </PropertyGroup>
     
    3940    <Reference Include="System.Runtime.Serialization" />
    4041    <Reference Include="System.ServiceModel" />
     42    <Reference Include="System.ServiceModel.Web" />
    4143    <Reference Include="System.Xml.Linq" />
    4244    <Reference Include="System.Data.DataSetExtensions" />
     
    4850    <Compile Include="Program.cs" />
    4951    <Compile Include="Properties\AssemblyInfo.cs" />
    50     <Compile Include="Service References\ServerServiceReference\Reference.cs">
    51       <AutoGen>True</AutoGen>
    52       <DesignTime>True</DesignTime>
    53       <DependentUpon>Reference.svcmap</DependentUpon>
    54     </Compile>
    5552  </ItemGroup>
    5653  <ItemGroup>
     
    5956  <ItemGroup>
    6057    <None Include="app.config" />
    61     <None Include="Service References\ServerServiceReference\item.xsd">
    62       <SubType>Designer</SubType>
    63     </None>
    64     <None Include="Service References\ServerServiceReference\item1.xsd">
    65       <SubType>Designer</SubType>
    66     </None>
    67     <None Include="Service References\ServerServiceReference\Service.wsdl" />
    68   </ItemGroup>
    69   <ItemGroup>
    70     <WCFMetadataStorage Include="Service References\ServerServiceReference\" />
    71   </ItemGroup>
    72   <ItemGroup>
    73     <None Include="Service References\ServerServiceReference\configuration91.svcinfo" />
    74   </ItemGroup>
    75   <ItemGroup>
    76     <None Include="Service References\ServerServiceReference\configuration.svcinfo" />
    77   </ItemGroup>
    78   <ItemGroup>
    79     <None Include="Service References\ServerServiceReference\Reference.svcmap">
    80       <Generator>WCF Proxy Generator</Generator>
    81       <LastGenOutput>Reference.cs</LastGenOutput>
    82     </None>
    8358  </ItemGroup>
    8459  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  • trunk/Utilities/Miscellaneous/WcfRest01/Client/Program.cs

    r169 r170  
    11using System;
    22using System.Collections.Generic;
     3using System.Collections.Specialized;
    34using System.Linq;
    45using System.Text;
     
    78using System.ServiceModel;
    89using System.ServiceModel.Description;
     10using System.ServiceModel.Web;
    911
    1012namespace Client
    1113{
     14    [ServiceContract]
     15    public interface IService
     16    {
     17        [OperationContract]
     18        [WebGet(UriTemplate = "/Method?input={input}", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml)]
     19        string Method(string input);
     20    }
     21
     22    public partial class ServiceClient :
     23        ClientBase<IService>,
     24        IService
     25    {
     26        public ServiceClient()
     27        {
     28        }
     29        public ServiceClient(string endpointConfigurationName) :
     30            base(endpointConfigurationName)
     31        {
     32        }
     33        public ServiceClient(string endpointConfigurationName, string remoteAddress) :
     34            base(endpointConfigurationName, remoteAddress)
     35        {
     36        }
     37        public ServiceClient(string endpointConfigurationName, EndpointAddress remoteAddress) :
     38            base(endpointConfigurationName, remoteAddress)
     39        {
     40        }
     41        public ServiceClient(System.ServiceModel.Channels.Binding binding, EndpointAddress remoteAddress) :
     42            base(binding, remoteAddress)
     43        {
     44        }
     45
     46        #region IService
     47        public string Method(string input)
     48        {
     49            return base.Channel.Method(input);
     50        }
     51        #endregion
     52    }
     53
    1254    class Program
    1355    {
    14         static void Main(string[] args)
     56        static void NonRestMain()
    1557        {
    16             Thread.Sleep(1000);
    17             ServerServiceReference.ServiceClient client = new ServerServiceReference.ServiceClient();
     58            //ServerServiceReference.ServiceClient client = new ServerServiceReference.ServiceClient();
     59            //for (int iteration = 0; ; iteration++)
     60            //{
     61            //    string input = char.ConvertFromUtf32('A' + (iteration / 10)) + (iteration % 10).ToString();
     62            //    string output = client.Method(input);
     63            //    Console.WriteLine(string.Format("Request sent/received, input {0}, output {1}", input, output));
     64            //    Thread.Sleep(2 * 1000);
     65            //}
     66        }
     67        static void RestMain()
     68        {
     69            ServiceClient client = new ServiceClient();
    1870            for (int iteration = 0; ; iteration++)
    1971            {
     
    2476            }
    2577        }
     78        static void Main(string[] args)
     79        {
     80#if DEBUG
     81            Thread.Sleep(1000);
     82#endif
     83            //NonRestMain();
     84            RestMain();
     85        }
    2686    }
    2787}
  • trunk/Utilities/Miscellaneous/WcfRest01/Client/app.config

    r169 r170  
    1 <?xml version="1.0" encoding="utf-8" ?>
     1<?xml version="1.0"?>
    22<configuration>
     3  <startup>
     4    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
     5  </startup>
    36  <system.serviceModel>
    4     <bindings>
    5       <basicHttpBinding>
    6         <binding name="BasicHttpBinding_IService" />
    7       </basicHttpBinding>
    8     </bindings>
    97    <client>
    10       <endpoint address="http://localhost:999/Service" binding="basicHttpBinding"
    11           bindingConfiguration="BasicHttpBinding_IService" contract="ServerServiceReference.IService"
    12           name="BasicHttpBinding_IService" />
     8      <endpoint name="rest" address="http://localhost:999/Service" binding="webHttpBinding" behaviorConfiguration="defaultBehaviorConfiguration" contract="Client.IService" />
    139    </client>
     10    <bindings/>
     11    <behaviors>
     12      <endpointBehaviors>
     13        <behavior name="defaultBehaviorConfiguration">
     14          <webHttp/>
     15        </behavior>
     16      </endpointBehaviors>
     17    </behaviors>
    1418  </system.serviceModel>
    1519</configuration>
  • trunk/Utilities/Miscellaneous/WcfRest01/Server/Program.cs

    r169 r170  
    77using System.ServiceModel;
    88using System.ServiceModel.Description;
     9using System.ServiceModel.Web;
    910
    1011namespace Server
     
    1415    {
    1516        [OperationContract]
     17        [WebGet(UriTemplate = "/Method?input={input}", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml)]
    1618        string Method(string input);
    1719    }
  • trunk/Utilities/Miscellaneous/WcfRest01/Server/Server.csproj

    r169 r170  
    5151  </ItemGroup>
    5252  <ItemGroup>
    53     <None Include="app.config" />
     53    <None Include="app.config">
     54      <SubType>Designer</SubType>
     55    </None>
    5456  </ItemGroup>
    5557  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  • trunk/Utilities/Miscellaneous/WcfRest01/Server/app.config

    r169 r170  
    77    <services>
    88      <service name="Server.Service" behaviorConfiguration="defaultServiceBehavior">
    9         <endpoint contract="Server.IService" address="Service" binding="basicHttpBinding" behaviorConfiguration="defaultEndpointBehavior"/>
     9        <endpoint contract="Server.IService" address="Service" binding="webHttpBinding" behaviorConfiguration="restEndpointBehavior"/>
    1010        <host>
    1111          <baseAddresses>
     
    1919        <binding name="defaultBinding"/>
    2020      </basicHttpBinding>
     21      <webHttpBinding>
     22      </webHttpBinding>
    2123    </bindings>
    2224    <behaviors>
     
    3032        <behavior name="defaultEndpointBehavior">
    3133        </behavior>
     34        <behavior name="restEndpointBehavior">
     35          <webHttp/>
     36        </behavior>
    3237      </endpointBehaviors>
    3338    </behaviors>
  • trunk/Utilities/Miscellaneous/WcfRest01/WcfRest01.sln

    r169 r170  
    55EndProject
    66Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client", "Client\Client.csproj", "{E9D0A60F-B9D3-4C07-931E-FCBBE5057DFB}"
     7        ProjectSection(ProjectDependencies) = postProject
     8                {CA3B4729-47B2-419C-9EF0-146539E3CAC6} = {CA3B4729-47B2-419C-9EF0-146539E3CAC6}
     9        EndProjectSection
    710EndProject
    811Global
Note: See TracChangeset for help on using the changeset viewer.