silverlight
发布时间:2022-05-04 发布网站:大佬教程 code.js-code.com
大佬教程收集整理的这篇文章主要介绍了稳扎稳打Silverlight(39) - 3.0通信之二进制XML通信, 本地连接,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
概述
[索引页] [源码下载] 稳扎稳打Silverlight(3
9) - 3.0通信之二进制XML通信, 本地连接 作者: webabcd 介绍 Silverlight 3.0 通信的新增功能 二进制XML通信 - 与 WCF 服务间通信,可以使用二进制 XML 传递数据(提高传输性能) 本地连接 - 允许客户端的两个 Silverlight 程序之间直接进行通信(不用通过服务端) 在线DEMO
@H_
674_19@客户端
@H_
674_19@BinaryXm
l.xaml
<
navigation:Page
x:Class
="Silverlight30.Communication.binaryXml"
xmlns
="http://scheR_130_11845@as.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x
="http://scheR_130_11845@as.microsoft.com/winfx/2006/xaml"
xmlns:d
="http://scheR_130_11845@as.microsoft.com/expression/blend/2008"
xmlns:mc
="http://scheR_130_11845@as.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable
="d"
xmlns:navigation
="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
d:DesignWidth
="640"
d:DesignHeight
="480"
title
="BinaryXml Page"
>
<
Grid
x:Name
="LayoutRoot"
>
<
StackPanel
Orientation
="Horizontal"
Height
="30"
>
<!--
支持二进制 XML 通信
-->
<
Text@L_489_24@
x:Name
="txtName"
text
="webabcd"
/>
<
Button
x:Name
="btnHelloConfig"
Content
="引用服务后(使用代理),通过配置的方式与服务端做二进制XML通信"
Click
="btnHelloConfig_Click"
/>
<
Button
x:Name
="btnHelloCoding"
Content
="引用服务后(使用代理),通过编程的方式与服务端做二进制XML通信"
Click
="btnHelloCoding_Click"
/>
</
StackPanel
>
</
Grid
>
</
navigation:Page
>
@H_
674_19@BinaryXm
l.xam
l.cs
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Net;
using
System.Windows;
using
System.Windows.Controls;
using
System.Windows.Documents;
using
System.Windows.Input;
using
System.Windows.Media;
using
System.Windows.Media.Animation;
using
System.Windows.Shapes;
using
System.Windows.Navigation;
using
Silverlight30.binaryXmlservice;
using
System.serviceModel.ChAnnels;
using
System.serviceModel;
namespace
Silverlight30.Communication
{
public partial class BinaryXml : Page
{
public BinaryXml()
{
initializeComponent();
}
void client_HelloCompleted(object sender, HelloCompletedEventArgs E)
{
if (e.Error == null)
message@L_489_24@.Show(e.Result);
else
message@L_489_24@.Show(e.Error.ToString());
}
private void btnHelloConfig_Click(object sender, routedEventArgs E)
{
// 通过配置文件(serviceReferences.CLIENtConfig)的方式调用以二进制 XML 通信的 WCF 服务(需要使用代理)
BinaryXmlserviceClient client = new BinaryXmlserviceClient();
client.HelloCompleted += new EventHandler<HelloCompletedEventArgs>(client_HelloCompleted);
client.HelloAsync(txtName.Text);
}
private void btnHelloCoding_Click(object sender, routedEventArgs E)
@H_340_1489@
{
// 通过编程的方式调用以二进制 XML 通信的 WCF 服务(需要使用代理)
BinarymessageEncodingBindingElement binary = new BinarymessageEncodingBindingElement();
httpTransportBindingElement transport = new httpTransportBindingElement();
CustomBinding binding = new CustomBinding(binary, transport);
EndpointAddress address = new EndpointAddress("http://localhost:8616/BinaryXmlservice.svc");
BinaryXmlserviceClient client = new BinaryXmlserviceClient(binding, address);
client.HelloCompleted += new EventHandler<HelloCompletedEventArgs>(client_HelloCompleted);
client.HelloAsync(txtName.Text);
}
}
}
大佬总结
以上是大佬教程为你收集整理的稳扎稳打Silverlight(39) - 3.0通信之二进制XML通信, 本地连接全部内容,希望文章能够帮你解决稳扎稳打Silverlight(39) - 3.0通信之二进制XML通信, 本地连接所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。