我如何使用REST wcf服务-意思是“获取"浏览器对wcf的请求(无配置) [英] How can i use REST wcf service - means, "get" requests from browser to wcf (without configuration)

查看:90
本文介绍了我如何使用REST wcf服务-意思是“获取"浏览器对wcf的请求(无配置)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在尝试实现wcf服务,这也有一个常规调用,也有一个Web调用(返回html).

这是我的合同:

Hello, i''m trying to implement a wcf service, thats also have a regular call, and also have a web call (that returns html).

this is my contract:

[OperationContract]
void WriteEntry(string msg);

[WebGet]
[OperationContract]
string GetLogPage();



这是服务器代码:



this is the server code:

ServiceHost svh = null;
            try
            {
                svh = new ServiceHost(typeof(WCFLoggerService));

                svh.AddServiceEndpoint(typeof(ILoggerService),
                    new BasicHttpBinding(),
                    ServerURI.Scheme + "://" + ServerURI.Authority);
                svh.Open();

                // wait untill stop is issued.
                stopFlag.WaitOne();
            }
            catch (Exception e)
            {
                EventLog.WriteEntry("WebAppender", "Could not start wcf service, " + e.Message);
            }
            finally
            {
                if (svh != null && (svh.State == CommunicationState.Opened ||
                                    svh.State == CommunicationState.Opening))
                {
                    svh.Close();
                }
            }







how to i add programiclly the browser get request to the server?

推荐答案

我知道你说没有配置,但是据我所知,这就像想要你的服务器一样.汽车让您无需任何轮子即可工作.

看看这篇文章
使用ASP.NET AJAX在JavaScript中使用WCF服务的入门指南 [
I know you say without configuration, but as far as I know that''s like wanting your car to drive you to work without any wheels.

Have a look at this article
A beginner’s guide for consuming a WCF service in JavaScript using ASP.NET AJAX[^]


好的,我可以看不到浏览器与它有什么关系,如果没有自己编写代码就无法使浏览器做任何事情.

如果您到WCF服务的地址发生了很大变化,我建议您研究UDP,这里有两篇文章
用于WCF的WS-发现 [ WCF 4.0服务发现-将绑定添加到发现中 [
Ok then I can''t see how a browser has anything to do with it, you can''t make a browser do anything without writing the code yourself.

if your address to your WCF service changes that much I will suggest you look into UDP here are two articles
WS-Discovery for WCF[^]
WCF 4.0 Service Discovery - Adding the Binding to the Discovery[^]


这篇关于我如何使用REST wcf服务-意思是“获取"浏览器对wcf的请求(无配置)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆