Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>though I dont know what is your issue may be something wrong with your generate code Here is full working example for sending a string from client and then receiving it from server.</p> <pre><code>using System; using System.Runtime.Serialization; using System.IO; using System.ServiceModel; using System.ServiceModel.Channels; namespace MySpace { [DataContract] public class Data { [DataMember] public string MyString; } [ServiceContract] public interface IService { [OperationContract] Data Method(Data dd); } public class Service : IService { public Data Method(Data dd) { dd.MyString = dd.MyString + " String from Server."; return dd; } } class Program { static void Main(string[] args) { string Url = "http://localhost:8000/"; Binding binding = new BasicHttpBinding(); ServiceHost host = new ServiceHost(typeof(Service)); host.AddServiceEndpoint(typeof(IService), binding, Url); host.Open(); ChannelFactory&lt;IService&gt; fac = new ChannelFactory&lt;IService&gt;(binding); fac.Open(); IService proxy = fac.CreateChannel(new EndpointAddress(Url)); Data d = new Data(); d.MyString = "String from client."; d = proxy.Method(d); fac.Close(); host.Close(); Console.WriteLine("Result after calling \n " + d.MyString); Console.ReadLine(); } } } </code></pre> <p>Update: ran code without DataContract by just passing string it works fab</p> <pre><code>using System; using System.Runtime.Serialization; using System.IO; using System.ServiceModel; using System.ServiceModel.Channels; namespace MySpace { [ServiceContract] public interface IService { [OperationContract] string Method(string dd); } public class Service : IService { public string Method(string dd) { dd =dd+ " String from Server."; return dd; } } class Program { static void Main(string[] args) { string Url = "http://localhost:8000/"; Binding binding = new BasicHttpBinding(); ServiceHost host = new ServiceHost(typeof(Service)); host.AddServiceEndpoint(typeof(IService), binding, Url); host.Open(); ChannelFactory&lt;IService&gt; fac = new ChannelFactory&lt;IService&gt;(binding); fac.Open(); IService proxy = fac.CreateChannel(new EndpointAddress(Url)); string d = proxy.Method("String from client."); fac.Close(); host.Close(); Console.WriteLine("Result after calling \n " + d); Console.ReadLine(); } } } </code></pre> <p>Update 3 I still believe there was something wrong with your generated code/proxies as here is test with different interfaces on client/server ( Any way you can ignore it, if your problem is already solved :)</p> <pre><code>using System; using System.Runtime.Serialization; using System.IO; using System.ServiceModel; using System.ServiceModel.Channels; using System.ServiceModel.Description; namespace MyClient { [ServiceContract] public interface IService { [OperationContract] string Method(string dd); } } namespace MyServer { [ServiceContract] public interface IService { [OperationContract] string Method(string dd); } } namespace MySpace { public class Service :MyServer.IService { public string Method(string dd) { dd =dd+ " String from Server."; return dd; } } class Program { static void Main(string[] args) { string Url = "http://localhost:8000/"; Binding binding = new BasicHttpBinding(); ServiceHost host = new ServiceHost(typeof(Service)); host.AddServiceEndpoint(typeof(MyServer.IService), binding, Url); host.AddDefaultEndpoints(); host.Open(); ChannelFactory&lt;MyClient.IService&gt; fac = new ChannelFactory&lt;MyClient.IService&gt;(binding); fac.Open(); MyClient.IService proxy = fac.CreateChannel(new EndpointAddress(Url)); string d = proxy.Method("String from client."); fac.Close(); host.Close(); Console.WriteLine("Result after calling \n " + d); Console.ReadLine(); Console.ReadLine(); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload