ASP.NET Web Services:构建与高级应用指南
1. 动态调整服务地址
在开发过程中,为了使代码中的服务地址与测试Web服务器当前使用的端口号同步,我们可以动态改变地址。具体操作是获取Silverlight页面的URL并找到其端口号,因为Silverlight页面和Web服务托管在同一Web服务器上。以下是实现该功能的代码:
' Create a new URL for the TestService.svc service using the current port number.
Dim address As New EndpointAddress( _
"http://localhost:" & HtmlPage.Document.DocumentUri.Port & _
"/SilverlightApplication.Web/TestService.svc")
' Use the new address with the proxy object.
Dim proxy As New TestServiceClient()
proxy.Endpoint.Address = address
使用类似的代码,我们可以基于当前Silverlight页面创建URL,只要将Web服务和Silverlight应用程序放在同一Web文件夹中,无论部署到何处,Web服务都能正常工作。
2. Web服务数据类型
创建用于Silverlight的Web服务时,数据类型限于.NET核心数据类型,包括字符串、布尔值、字节、数值数据类型、枚举
超级会员免费看
订阅专栏 解锁全文

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



