ASP.NET Web Services 开发全解析
1. 动态设置 Web 服务地址
在开发过程中,我们常常需要动态设置 Web 服务的地址,以确保服务能在不同环境下正常运行。以下是两种常见的设置方式:
- 使用硬编码端口 :
' Create the proxy class.
Dim proxy As New TestServiceClient()
' Use the port that's hard-coded in the project properties.
Dim address As New EndpointAddress( _
"http://localhost:54752/ASPWebSite/TestService.svc")
' Apply the new URI.
proxy.Endpoint.Address = address
- 动态获取端口 :通过获取 Silverlight 页面的 URL 来动态确定端口号,使服务地址与测试 Web 服务器当前使用的端口同步。
' Create a new URL for the TestService.svc service using the current port number.
Dim address As New EndpointAddress( _
"http://localhost:" & HtmlP
ASP.NET Web Services 开发全解析
超级会员免费看
订阅专栏 解锁全文

67

被折叠的 条评论
为什么被折叠?



