using System.ServiceModel.Web;\r
using System.ServiceModel.Description;\r
using System.ServiceModel.Dispatcher;\r
+using System.Net;\r
+\r
+using MonoTests.Helpers;\r
\r
namespace MonoTests.System.ServiceModel.Web\r
{\r
[Category("NotWorking")]\r
public void ServiceDebugBehaviorTest () {\r
\r
- var host = new WebServiceHost (typeof (MyService), new Uri ("http://localhost:30158/"));\r
+ var host = new WebServiceHost (typeof (MyService), new Uri ("http://" + NetworkHelpers.LocalEphemeralEndPoint().ToString()));\r
ServiceEndpoint webHttp = host.AddServiceEndpoint ("MonoTests.System.ServiceModel.Web.WebServiceHostTest+MyService", new WebHttpBinding (), "WebHttpBinding");\r
\r
Assert.AreEqual (true, host.Description.Behaviors.Find<ServiceDebugBehavior> ().HttpHelpPageEnabled, "HttpHelpPageEnabled #1");\r
[Category ("NotWorking")]\r
public void WebHttpBehaviorTest1 () {\r
\r
- var host = new WebServiceHost (typeof (MyService), new Uri ("http://localhost:30158/"));\r
+ var host = new WebServiceHost (typeof (MyService), new Uri ("http://" + NetworkHelpers.LocalEphemeralEndPoint().ToString()));\r
ServiceEndpoint webHttp = host.AddServiceEndpoint ("MonoTests.System.ServiceModel.Web.WebServiceHostTest+MyService", new WebHttpBinding (), "WebHttpBinding");\r
ServiceEndpoint basicHttp = host.AddServiceEndpoint ("MonoTests.System.ServiceModel.Web.WebServiceHostTest+MyService", new BasicHttpBinding (), "BasicHttpBinding");\r
\r
[Category("NotWorking")]\r
public void WebHttpBehaviorTest2 () {\r
\r
- var host = new WebServiceHost (typeof (MyService), new Uri ("http://localhost:30158/"));\r
+ var host = new WebServiceHost (typeof (MyService), new Uri ("http://" + NetworkHelpers.LocalEphemeralEndPoint().ToString()));\r
ServiceEndpoint webHttp = host.AddServiceEndpoint ("MonoTests.System.ServiceModel.Web.WebServiceHostTest+MyService", new WebHttpBinding (), "WebHttpBinding");\r
MyWebHttpBehavior behavior = new MyWebHttpBehavior ();\r
behavior.ApplyDispatchBehaviorBegin += delegate {\r
[Test]\r
public void ServiceBaseUriTest () {\r
\r
- var host = new WebServiceHost (typeof (MyService), new Uri ("http://localhost:30158/"));\r
+ var host = new WebServiceHost (typeof (MyService), new Uri ("http://" + NetworkHelpers.LocalEphemeralEndPoint().ToString()));\r
Assert.AreEqual (0, host.Description.Endpoints.Count, "no endpoints yet");\r
host.Open ();\r
Assert.AreEqual (1, host.Description.Endpoints.Count, "default endpoint after open");\r
}\r
}\r
\r
+ [Test]\r
+ public void Connect ()\r
+ {\r
+ var url = "http://" + NetworkHelpers.LocalEphemeralEndPoint().ToString();\r
+ var host = new WebServiceHost (typeof (DemoService), new Uri\r
+ (url));\r
+ try {\r
+ host.Open ();\r
+ var wc = new WebClient();\r
+ wc.DownloadString(url + "/testData");\r
+ Console.WriteLine();\r
+ } finally {\r
+ host.Close();\r
+ }\r
+ }\r
+ \r
+ [ServiceContract]\r
+ interface IDemoService {\r
+ [OperationContract]\r
+ [WebInvoke(UriTemplate = "/{testData}",\r
+ Method = "GET",\r
+ RequestFormat = WebMessageFormat.Json,\r
+ ResponseFormat = WebMessageFormat.Json)]\r
+ void UpdateAttribute(string testData);\r
+ }\r
+\r
+ public class DemoService : IDemoService {\r
+ public void UpdateAttribute(string testData)\r
+ {\r
+ Console.WriteLine ("got it: "+testData);\r
+ }\r
+ }\r
}\r
}\r
#endif\r