Web服务查询 [英] Web Service queries

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

问题描述

你好。


我用C#(VS2008)和ASP.Net编写了一个Web服务,一切正常。我遇到的问题是当我公开Web服务然后尝试从测试应用程序订阅它的方法时。


当我在VS2008中启动Web服务时,网址具有通常的地址类型 HTTP://本地主机:3998 / Webservice1 /服务.asmx.asmx 所以我发现如果我想在我的测试应用程序中使用Web方法,那么我必须添加Web引用并将完整的URL复制/粘贴到测试应用程序中。 />

我觉得这是错误的做事方式因为我最终想要公开这个网络服务供其他人使用,问题是我该如何做到这一点以及我在哪里放置所有必要文件?我是否必须在Web服务中使用Build / Publish网站选项?那么我如何在另一台机器上看到Web服务?希望你能在这里得到我想要的想法..?

大多数书籍等似乎都提供了在同一台机器上提供的Web服务和相应订阅应用程序的示例。


谢谢。


M:)

Hi there.

I have written a web service in C# (VS2008) and ASP.Net and all is working fine with it. The problem I am having is when I expose the web service and hence then try to subscribe to its methods from a test application.

When I start up the web service in VS2008, the url has the usual address-type of http://localhost:3998/Webservice1/Service.asmx.asmx and so I am finding that if I wish to use the web methods in my test application, then I have to Add a Web Reference and copy/paste in the full url to the test application.

I feel this is the wrong way to do things so as I ultimately want to publiush this web service for other people to use, the question is how do I do this and where do I place all the necesary files? Do I have to use the Build/Publish web site option with the web service? It is then how do I see the web service on a different machine? Hopefully you get the idea with what I am looking for here..?

Most books and the such seem to give examples of the web service and corresponding subscribing apps to be on the same machine.

Thank you.

M :)

推荐答案

还有以上是否总是需要在Web服务器的Web地址中使用端口号?


谢谢。


Mark: )
Also with the above, is it always necessary to have the port number in the web address for the web server?

Thank you.

Mark :)


你好:)


查看这篇文章部署Web服务


您需要运行Web服务器IIS。

然后您将Web服务发布(或手动移动)到Web服务器。

使用Web服务的客户端必须知道Web服务具有的URL已发布/移至。为简单起见,使用该URL通过复制/粘贴URL(或使用添加Web引用)来引用应用程序中的Web服务。我认为使用Look Up Service可以解决这个问题,但是现在如何解决这个问题(自从我开发了Web服务以来已经有一段时间了)。


如果您在特殊端口(我认为不是端口80)上运行Web服务,您只需要指定端口。


-Frinny
Hi there :)

Check out this article on deploying web services.

You need a web server running IIS.
You then publish (or manually move) the Web Service to the web server.
The client that consumes the web service must know the URL that the web service has been published/moved to. For simplicity sake, use that URL to reference the web service in your application by copy/pasting the URL (or using the "add web reference"). I think there is a way around this using a Look Up Service but how to do this is escaping me right now (it''s been a while since I''ve developed with web services).

You are only going to need to specify the port if you are running the Web Service on a special port (other than port 80 I think).

-Frinny


谢谢你。就Web服务而言,这将是 http://machine-ip-number/WebService1/Service.asmx ..?

我问这个好像我去虚拟在IIS中的目录并右键单击相应的asmx文件并选择浏览,我收到错误:


无法显示XML页面

无法查看XML输入使用XSL样式表。请更正错误,然后单击刷新按钮,或稍后重试。



---------------------------------- ----------------------------------------------


名称以无效字符开头。处理资源http://localhost/AddSearch/Service.asmx时出错。第1行,......


<%@ WebService语言=" C#"代码隐藏= QUOT;〜/ App_Code文件/ Service.cs"类= QUOT;服务" %>

- ^


谢谢。


马克:)
Thank you for that. In terms of the web service, will this be http://machine-ip-number/WebService1/Service.asmx..?

I ask this as if I go to the virtual directory in IIS and right-click the respective asmx file and select Browse, I get the error:

The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.


--------------------------------------------------------------------------------

A name was started with an invalid character. Error processing resource ''http://localhost/AddSearch/Service.asmx''. Line 1,...

<%@ WebService Language="C#" CodeBehind="~/App_Code/Service.cs" Class="Service" %>
-^

Thank you.

Mark :)


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

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