-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
LU Yulong
authored and
LU Yulong
committed
Jul 12, 2017
1 parent
6f87846
commit cd46a3c
Showing
26 changed files
with
1,104 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.ServiceModel; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace InterfaceLib | ||
{ | ||
[ServiceContract] | ||
public interface IWcfService | ||
{ | ||
[OperationContract] | ||
int GetData(); | ||
|
||
[OperationContract] | ||
void SetData(int p1, int p2); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> | ||
</startup> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.ServiceModel; | ||
using InterfaceLib; | ||
using System.ServiceModel.Channels; | ||
using System.ServiceModel.Description; | ||
|
||
namespace WcfCallDemo | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
AddressHeader header = AddressHeader.CreateAddressHeader("Test", "http://fitsco.com.cn", "Luyulong"); | ||
EndpointAddress address = new EndpointAddress(new Uri("net.pipe://localhost/Services/WcfService"), header); | ||
Binding bind = new NetNamedPipeBinding(); | ||
ContractDescription contract = ContractDescription.GetContract(typeof(IWcfService)); | ||
ServiceEndpoint endpoint = new ServiceEndpoint(contract, bind, address); | ||
ClientViaBehavior clientBehavior = new ClientViaBehavior(new Uri("net.pipe://localhost/Services/WcfService1")); | ||
endpoint.EndpointBehaviors.Add(clientBehavior); | ||
ChannelFactory<IWcfService> factory = new ChannelFactory<IWcfService>(endpoint); | ||
|
||
var obj = factory.CreateChannel(); | ||
Console.ForegroundColor = ConsoleColor.Cyan; | ||
Console.WriteLine(obj.GetData()); | ||
obj.SetData(12, 18); | ||
Console.WriteLine(obj.GetData()); | ||
Console.ResetColor(); | ||
Console.Read(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// 有关程序集的常规信息通过以下 | ||
// 特性集控制。更改这些特性值可修改 | ||
// 与程序集关联的信息。 | ||
[assembly: AssemblyTitle("WcfCallDemo")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("Microsoft")] | ||
[assembly: AssemblyProduct("WcfCallDemo")] | ||
[assembly: AssemblyCopyright("Copyright © Microsoft 2017")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// 将 ComVisible 设置为 false 使此程序集中的类型 | ||
// 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型, | ||
// 则将该类型上的 ComVisible 特性设置为 true。 | ||
[assembly: ComVisible(false)] | ||
|
||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID | ||
[assembly: Guid("d85c2d67-b15c-4bb8-a22c-ebd00e75cd3d")] | ||
|
||
// 程序集的版本信息由下面四个值组成: | ||
// | ||
// 主版本 | ||
// 次版本 | ||
// 生成号 | ||
// 修订号 | ||
// | ||
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, | ||
// 方法是按如下所示使用“*”: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{9764C28D-F2B2-4AF8-B02E-FA2D825B3EE5}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>WcfCallDemo</RootNamespace> | ||
<AssemblyName>WcfCallDemo</AssemblyName> | ||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.ServiceModel" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="App.config" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\InterfaceLib\InterfaceLib.csproj"> | ||
<Project>{10835cba-a1cb-436e-82af-333d2d659c9f}</Project> | ||
<Name>InterfaceLib</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> | ||
</startup> | ||
<system.serviceModel> | ||
<bindings> | ||
<netNamedPipeBinding> | ||
<binding name="NetNamedPipeBinding_IWcfService" /> | ||
</netNamedPipeBinding> | ||
</bindings> | ||
<client> | ||
<endpoint address="net.pipe://localhost/Services/WcfService" | ||
binding="netNamedPipeBinding" bindingConfiguration="NetNamedPipeBinding_IWcfService" | ||
contract="ServiceReference.IWcfService" name="NetNamedPipeBinding_IWcfService"> | ||
<headers> | ||
<Test xmlns="http://fitsco.com.cn">Luyulong</Test> | ||
</headers> | ||
<identity> | ||
<userPrincipalName value="[email protected]" /> | ||
</identity> | ||
</endpoint> | ||
</client> | ||
</system.serviceModel> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace WcfHttpRefCall | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
ServiceReference.WcfServiceClient obj = new ServiceReference.WcfServiceClient(); | ||
Console.ForegroundColor = ConsoleColor.Yellow; | ||
Console.BackgroundColor = ConsoleColor.Blue; | ||
Console.WriteLine(obj.GetData()); | ||
obj.SetData(12, 18); | ||
Console.WriteLine(obj.GetData()); | ||
Console.ResetColor(); | ||
Console.Read(); | ||
} | ||
} | ||
} |
Oops, something went wrong.