EXE中的Web服务 [英] Web service in EXE

查看:72
本文介绍了EXE中的Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我见过应用程序,如果windows exe表单正在运行,它会发布一个web

服务。没有IIS文件夹或虚拟目录。

是否有人有关于如何做到这一点的信息?

I''ve seen apps where if a windows exe form is running, it publishes a web
service. There is no IIS folders or virtual directories required. Does
anyone have information on how to do this?

推荐答案

Jeremy Chapman写道:
Jeremy Chapman wrote:
我见过应用程序,如果Windows exe表单正在运行,它会发布一个
Web服务。没有IIS文件夹或虚拟目录。
有没有人有关于如何做到这一点的信息?
I''ve seen apps where if a windows exe form is running, it publishes a
web service. There is no IIS folders or virtual directories required.
Does anyone have information on how to do this?




是的。首先,你需要自己动手WSE2.0 [1]。接下来,编写一个源自SoapService的Web服务

类,如下所示:


< codeSnippet language =" C#">

公共密封类MyService:SoapService

{

[SoapMethod(" MySoapAction")]

public void MyWebMethod()

{

// TODO:在这里做点什么

}

}

< ; / codeSnippet>


最后,要在您的WinForms应用程序中托管此服务,您需要做的就是

以下内容:

< codeSnippet language =" C#">

protected override void OnLoad(EventArgs args)

{

SoapReceivers .Add(new EndpointReference(new Uri(" http://" + Dns.GetHostName()

+" / MyService")),typeof(MyService));


base.OnLoad(args);

}

< / codeSnippet>


那个这就是它的全部。如果您只是更改http:,您可以使用较低级别的肥皂TCP

协议来托管它。 tosoap.tcp:。阅读所有关于这个过程

这里[2]。


HTH,

画了


[1] http://msdn.microsoft.com/webservices / building / wse /

[2] http://msdn.microsoft.com/library/de....asp?frame=tru



Yup. First you need to get yourself WSE2.0[1]. Next, write a web service
class that derives from SoapService, like so:

<codeSnippet language="C#">
public sealed class MyService : SoapService
{
[SoapMethod("MySoapAction")]
public void MyWebMethod()
{
// TODO: do something here
}
}
</codeSnippet>

Finally, to host this service in your WinForms app all you need to do is
the following:

<codeSnippet language="C#">
protected override void OnLoad(EventArgs args)
{
SoapReceivers.Add(new EndpointReference(new Uri("http://" + Dns.GetHostName()
+ "/MyService")), typeof(MyService));

base.OnLoad(args);
}
</codeSnippet>

That''s all there is to it. You could host it with the lower level soap TCP
protocol if you just change "http:" to "soap.tcp:". Read all about this process
here[2].

HTH,
Drew

[1] http://msdn.microsoft.com/webservices/building/wse/
[2] http://msdn.microsoft.com/library/de....asp?frame=tru


太棒了!我会试试这个。

Drew Marsh <博士**** @ hotmail.no.spamming.com>在消息中写道

news:85 ********************* @ msnews.microsoft.com。 ..
Brilliant! I''ll try this.
"Drew Marsh" <dr****@hotmail.no.spamming.com> wrote in message
news:85*********************@msnews.microsoft.com. ..
Jeremy Chapman写道:
Jeremy Chapman wrote:
我见过应用程序,如果windows exe表单正在运行,它会发布一个
Web服务。没有IIS文件夹或虚拟目录。
有没有人有关于如何做到这一点的信息?
是的。首先,你需要自己动手WSE2.0 [1]。接下来,编写一个源自SoapService的Web服务类,如下所示:

< codeSnippet language =" C#">
公共密封类MyService:SoapService
{
[SoapMethod(" MySoapAction)]]
public void MyWebMethod()
// TODO:在这里做点什么
}
}
< / codeSnippet>

最后,要在您的WinForms应用程序中托管此服务,您需要做的就是以下内容:

< ; codeSnippet language =" C#">
protected override void OnLoad(EventArgs args)
{SoapReceivers.Add(new EndpointReference(new Uri(" http://" +)
I''ve seen apps where if a windows exe form is running, it publishes a
web service. There is no IIS folders or virtual directories required.
Does anyone have information on how to do this?
Yup. First you need to get yourself WSE2.0[1]. Next, write a web service
class that derives from SoapService, like so:

<codeSnippet language="C#">
public sealed class MyService : SoapService
{
[SoapMethod("MySoapAction")]
public void MyWebMethod()
{
// TODO: do something here
}
}
</codeSnippet>

Finally, to host this service in your WinForms app all you need to do is
the following:

<codeSnippet language="C#">
protected override void OnLoad(EventArgs args)
{
SoapReceivers.Add(new EndpointReference(new Uri("http://" +



Dns.GetHostName()+" / MyService")),typeof(MyService));

base.OnLoad(args);
}
< / codeSnippet>

这就是它的全部内容。如果您只是更改http:,则可以使用较低级别的soap TCP
协议来托管它。 tosoap.tcp:。在这里阅读关于这个
过程的全部内容[2]。

HTH,
画了

[1] http://msdn.microsoft.com/webservices/building/wse/
[2]
http://msdn.microsoft.com/library/de...asp?frame=true



我遇到了一些障碍,


在SoapReceivers.Add方法中,引发了一个异常消息

WSE803:A Active HTTP Listening需要有效的HttpContext。


这是配置问题吗?在WSE803上,帮助或google都没有返回任何内容



" Drew Marsh" <博士**** @ hotmail.no.spamming.com>在消息中写道

news:85 ********************* @ msnews.microsoft.com。 ..
I''m running into a bit of a snag,

On the SoapReceivers.Add method, An exception gets raised with the message
WSE803: A valid HttpContext is required for Active HTTP Listening.

Is this a configuration issue? Neither the help or google return anything
on WSE803
"Drew Marsh" <dr****@hotmail.no.spamming.com> wrote in message
news:85*********************@msnews.microsoft.com. ..
Jeremy Chapman写道:
Jeremy Chapman wrote:
我见过应用程序,如果windows exe表单正在运行,它会发布一个
Web服务。没有IIS文件夹或虚拟目录。
有没有人有关于如何做到这一点的信息?
是的。首先,你需要自己动手WSE2.0 [1]。接下来,编写一个源自SoapService的Web服务类,如下所示:

< codeSnippet language =" C#">
公共密封类MyService:SoapService
{
[SoapMethod(" MySoapAction)]]
public void MyWebMethod()
// TODO:在这里做点什么
}
}
< / codeSnippet>

最后,要在您的WinForms应用程序中托管此服务,您需要做的就是以下内容:

< ; codeSnippet language =" C#">
protected override void OnLoad(EventArgs args)
{SoapReceivers.Add(new EndpointReference(new Uri(" http://" +)
I''ve seen apps where if a windows exe form is running, it publishes a
web service. There is no IIS folders or virtual directories required.
Does anyone have information on how to do this?
Yup. First you need to get yourself WSE2.0[1]. Next, write a web service
class that derives from SoapService, like so:

<codeSnippet language="C#">
public sealed class MyService : SoapService
{
[SoapMethod("MySoapAction")]
public void MyWebMethod()
{
// TODO: do something here
}
}
</codeSnippet>

Finally, to host this service in your WinForms app all you need to do is
the following:

<codeSnippet language="C#">
protected override void OnLoad(EventArgs args)
{
SoapReceivers.Add(new EndpointReference(new Uri("http://" +



Dns.GetHostName()+" / MyService")),typeof(MyService));

base.OnLoad(args);
}
< / codeSnippet>

这就是它的全部内容。如果您只是更改http:,则可以使用较低级别的soap TCP
协议来托管它。 tosoap.tcp:。在这里阅读关于这个
过程的全部内容[2]。

HTH,
画了

[1] http://msdn.microsoft.com/webservices/building/wse/
[2]
http://msdn.microsoft.com/library/de...asp?frame=true



这篇关于EXE中的Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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