Mam pytanie jak odwolac sie do zmiennej 'zmienna' znajdujacej sie w aplikacji serwera z poziomu aplikacji klienta ?
serwer - host
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using Usluga;
namespace Host
{
class KlasaHost
{
public string zmienna = "";
static void Main(string[] args)
{
Console.WriteLine("Host WCF");
using (ServiceHost sh = new ServiceHost(typeof(KlasaUsluga)))
{
sh.Open();
Console.WriteLine("WCF Serwis gotowy!");
Console.ReadLine();
}
}
}
}
App.Config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="Usluga.KlasaUsluga"
behaviorConfiguration="KlasaUslugaMEXBehavior">
<endpoint address=""
binding="basicHttpBinding"
contract="Usluga.IKlasaUsluga"/>
<!--włącz punkt końcowy MEX-->
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/KlasaUsluga"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="KlasaUslugaMEXBehavior">
<serviceMetadata httpGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
klient
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Klient.ServiceReference1;
namespace Klient
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
KlasaUslugaClient kuc = new KlasaUslugaClient();
this.textBox3.Text =
(kuc.Odpowiedz(Convert.ToInt32(textBox1.Text),
Convert.ToInt32(textBox2.Text))).ToString();
}
}
}
usluga
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
namespace Usluga
{
public class KlasaUsluga : IKlasaUsluga
{
public KlasaUsluga() { }
public int Odpowiedz(int liczba1, int liczba2)
{
return liczba1 + liczba2;
}
}
[ServiceContract]
public interface IKlasaUsluga
{
[OperationContract]
int Odpowiedz(int liczba1, int liczba2);
}
}