zoukankan      html  css  js  c++  java
  • 访问双工服务

    View Code
    // Code in the MainPage.xaml.cs page.

    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.ServiceModel;
    using System.ServiceModel.Channels;
    using DuplexClient.OrderService;


    namespace DuplexClient
    {
    public partial class MainPage : UserControl
    {

    public MainPage()
    {
    InitializeComponent();

    // If using the PollingDuplexHttpBinding on the service
    EndpointAddress address = new EndpointAddress("http://localhost:19021/Service1.svc");
    PollingDuplexHttpBinding binding
    = new PollingDuplexHttpBinding(PollingDuplexMode.MultipleMessagesPerPoll);

    DuplexServiceClient proxy
    = new DuplexServiceClient(binding, address);

    // If using a NetTcpBinding on the service
    // DuplexServiceClient proxy = new DuplexServiceClient();
    proxy.ReceiveReceived += new EventHandler<ReceiveReceivedEventArgs>(proxy_ReceiveReceived);
    proxy.OrderAsync(
    "Widget", 3);
    reply.Text
    = "Sent order of 3 Widgets." + Environment.NewLine;

    }

    void proxy_ReceiveReceived(object sender, ReceiveReceivedEventArgs e)
    {
    if (e.Error == null)
    {
    reply.Text
    += "Service reports Widget order is " + e.order.Status + "." + Environment.NewLine;

    if (e.order.Status == OrderStatus.Completed)
    {
    reply.Text
    += "Here is the completed order:" + Environment.NewLine;

    foreach (string order in e.order.Payload)
    {
    reply.Text
    += order + Environment.NewLine;
    }
    }

    }
    }

    }
    }

  • 相关阅读:
    你好,2021!
    庚子走,辛丑来,愿一切安好!
    花魂鸟魂总难留,鸟自无言花自羞
    熟悉的小胡同
    夜半听鼾声
    写在儿子22岁生日
    vue配置Azure Artifacts npm包源
    RabbitMQ出错:AMQP close-reason, initiated by Peer, code=530的解决办法
    .NET MVC存储图片到数据库的解决方案
    EF Core解决报错’EntityTypeBuilder未包含“ToTable”的定义‘的方法
  • 原文地址:https://www.cnblogs.com/landexia/p/1994439.html
Copyright © 2011-2022 走看看