[Mono-list] Mono 2.10.4 and WebServiceHost

Atsushi Eno atsushieno at veritas-vos-liberabit.com
Tue Aug 16 08:07:40 EDT 2011


Hi Bert,

Since I cannot guess what your client actually does, I only edited
the host address and ran the console server, then ran this:
wget http://localhost:8080/calc/hello?name=eno

and it worked fine, without dumping any error at server side.

(I only ran the test on master, but 2.10 should be the same - I
had kept committing the fixes on both master and 2.10 when
I used to work on the entire wcf stuff).

Atsushi Eno

> Hi Atsushi,
>
> Here is the code (from Microsofts site)
>
>
> using System;
> using System.ServiceModel;
> using System.ServiceModel.Description;
> using System.ServiceModel.Web;
>
> [ServiceContract]
> public interface ICalculator {
>      [OperationContract]
>      [WebGet(UriTemplate = "add?x={x}&y={y}", BodyStyle =
> WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
>      long Add(long x, long y);
>
>      [OperationContract]
>      [WebGet(UriTemplate = "sub?x={x}&y={y}", BodyStyle =
> WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
>      long Subtract(long x, long y);
>
>      [OperationContract]
>      [WebGet(UriTemplate = "mult?x={x}&y={y}", BodyStyle =
> WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
>      long Multiply(long x, long y);
>
>      [OperationContract]
>      [WebGet(UriTemplate = "div?x={x}&y={y}", BodyStyle =
> WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
>      long Divide(long x, long y);
>
>      [OperationContract]
>      [WebGet(UriTemplate = "hello?name={name}", BodyStyle =
> WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
>      string SayHello(string name);
>
>      [OperationContract]
>      [WebGet(UriTemplate = "now", BodyStyle = WebMessageBodyStyle.Wrapped,
> ResponseFormat = WebMessageFormat.Json)]
>      DateTime Now();
> }
>
> public class CalcService: ICalculator {
>      public long Add(long x, long y) {
>          return x + y;
>      }
>
>      public long Subtract(long x, long y) {
>          return x - y;
>      }
>
>      public long Multiply(long x, long y) {
>          return x * y;
>      }
>
>      public long Divide(long x, long y) {
>          return x / y;
>      }
>
>      public string SayHello(string name) {
>          return "Hello " + name;
>      }
>
>      public DateTime Now() {
>          return DateTime.Now;
>      }
> }
>
> class Program {
>
>      static void Main(string[] args) {
>          Uri baseAddress = new Uri("http://192.168.11.5:8080/");
>
>          WebServiceHost svcHost = new WebServiceHost(typeof(CalcService),
> baseAddress);
>
>          try {
>              svcHost.AddServiceEndpoint(typeof(ICalculator), new
> WebHttpBinding(), "calc");
>              svcHost.Open();
>
>              Console.WriteLine("Service is running");
>              Console.WriteLine("Press enter to quit...");
>              Console.ReadLine();
>
>              svcHost.Close();
>          } catch (CommunicationException cex) {
>              Console.WriteLine("An exception occurred: {0}", cex.Message);
>              svcHost.Abort();
>          }
>      }
> }
>
>
> Pretty straightforward ... I investigated the library code and found the
> Console.Write's in the following files ...
>
> mcs/class/System.ServiceModel/System.ServiceModel/ServiceHostBase.cs (line
> 558)
> mcs/class/System.ServiceModel.Dispatcher/BaseRequestProcessor.cs (line 34)
>
> BTW using the mono-2.10 branch from git
>
> TIA
>
> Bert
>
>
>
> --
> View this message in context:http://mono.1490590.n4.nabble.com/Mono-2-10-4-and-WebServiceHost-tp3744197p3746596.html
> Sent from the Mono - General mailing list archive at Nabble.com.
> _______________________________________________
> Mono-list maillist  -Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>
>
>



More information about the Mono-list mailing list