我正在尝试从我的计算机上自托管一些WCF RESTful服务,供本地网络上的计算机使用.我没有WCF的经验,在这方面我很大程度上是一个新手.我创建了一个非常基本的,剥离的控制台应用程序,看看我是否能让它运行起来.
static void Main(string[] args)
{
Uri httpUrl = new Uri("http://localhost:8090/");
var host = new WebServiceHost(typeof(TestClass), httpUrl);
var binding = new WebHttpBinding(); // NetTcpBinding();
host.AddServiceEndpoint(typeof(ITestClass), binding, "testing");
ServiceDebugBehavior stp = host.Description.Behaviors.Find<ServiceDebugBehavior>();
stp.HttpHelpPageEnabled = false;
host.Open();
Console.WriteLine("Commence with the testing!");
Console.ReadLine();
host.Close();
}
Run Code Online (Sandbox Code Playgroud)
这是服务代码:
[ServiceContract]
public interface ITestClass
{
[WebGet]
[OperationContract]
string TestMethod();
}
public class TestClass : ITestClass
{
public string TestMethod()
{
return "SUCCESS";
}
}
Run Code Online (Sandbox Code Playgroud)
从我本地机器上的浏览器,我可以发出一个简单的get请求并获取
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">SUCCESS</string>
Run Code Online (Sandbox Code Playgroud)
但是,当我输入时,我似乎无法从家庭网络上的任何浏览器ping此服务http://<service machine's IP>:8090/testing/testmethod.
任何人都可以告诉我,我缺少哪些配置,以使服务对我本地网络上的其他计算机可见,而无需DNS服务器?
我正在尝试创建一个用于控制WeMo设备的C#应用程序.我接着Bernacules给出的代码示例和方向在这里.
相关的代码位粘贴在下面.
private void GetAllDevices()
{
var finder = new UPnPDeviceFinder();
var foundDevices = new List<UPnPDevice>();
var deviceType = "upnp:rootdevice";
var devices = finder.FindByType(deviceType, 1);
foreach (UPnPDevice upnpDevice in devices)
{
if (upnpDevice.Type.StartsWith("urn:Belkin:"))
{
....
}
}
}
Run Code Online (Sandbox Code Playgroud)
当我迭代UPnPDeviceFinder找到的设备时,我想出了各种各样的东西,我的媒体服务器,在我的Android手机上运行的一些应用程序,我的Chromecast,但没有WeMos,甚至没有任何东西甚至在贝尔金钟中有贝尔金.
经过一番谷歌搜索,我发现这篇文章让我弄清楚如何查询每个设备的'setup.xml'.通过将上面代码中的"upnp:rootdevice"替换为xml中<DeviceType>的值(我相信它是"urn:Belkin:device:controllee:1"),我从UPnPDeviceFinder得到了0个结果.我猜Belkin最近改变了他们的配置,但是有更多网络笨拙的人可以告诉我有什么价值我可以使用'deviceType'找到我的WeMos?
我试图在WinForms应用程序中自我托管一个OWIN管道.该管道正在托管静态文件和Web Api v2内容.该实现在本地工作得很好,但我不确定我缺少什么才能从我的网络上的远程机器访问托管文件和API.
为了简单起见,我下载CodePlex从样品自主机的应用程序在这里,并试图使下面的修改的基地址后远程访问的测试方法(I尝试都运行在netsh regisration和我在管理员模式下运行)和I仍然无法访问它们.我需要在配置中更改哪些内容才能查看同一网络中其他计算机的内容?
static void Main()
{
string baseAddress = "http://*:10281/";
// Start OWIN host
using (WebApp.Start<Startup>(url: baseAddress))
{
// Create HttpCient and make a request to api/values
HttpClient client = new HttpClient();
HttpResponseMessage response = client.GetAsync("http://localhost:10281/api/values").Result;
Console.WriteLine(response);
Console.WriteLine(response.Content.ReadAsStringAsync().Result);
Console.ReadLine(); // Keeps the host from disposing immediately
}
}
Run Code Online (Sandbox Code Playgroud)
这是启动配置,非常基本的东西:
public class Startup
{
// This code configures Web API contained in the class Startup, which is additionally specified as the type parameter in WebApplication.Start
public …Run Code Online (Sandbox Code Playgroud) 我想写发送和使用作为概括GCM的CCS接收来自Android设备的通知第三方服务器应用程序在这里.我正在利用PushSharp处理从我的服务器应用程序发送通知,但我似乎无法找到有关如何在服务器级别接收消息的任何文档.是否支持或是否有另一个用于.NET的第三方XMPP库可以干净地处理这个问题?