如何动态指定EndPoint Address

wkun610 2010-04-12 10:04:31
在开发时用的<endpoint address="http://localhost:4951/...
怎么让他在发布后能够成功调试
...全文
1075 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
websco 2010-04-12
  • 打赏
  • 举报
回复
VS在生成代理类时,会自动生成5个构造函数,

public XXXClient() {
}

public XXXClient(string endpointConfigurationName) :
base(endpointConfigurationName) {
}

public XXXClient(string endpointConfigurationName, string remoteAddress) :
base(endpointConfigurationName, remoteAddress) {
}

public XXXClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :
base(endpointConfigurationName, remoteAddress) {
}

public XXXClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
base(binding, remoteAddress) {
}

其中,public XXXClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) 最为灵活,不依赖于 ServiceReferences.ClientConfig ,而其他4个则均依赖于ServiceReferences.ClientConfig 中的 bindingConfiguration名称

<endpoint address="http://xxxxxx/XXX.svc" binding="customBinding"
bindingConfiguration="endpointConfigurationName" contract="XXXXX"
name="CustomBinding_XXX" />
llszn 2010-04-12
  • 打赏
  • 举报
回复
string host=HtmlPage.Document.DocumentUri.Host;
client.Endpoint.Address = new System.ServiceModel.EndpointAddress(new Uri(string.Format("http://{0}:8731/LoginService", host)));
//8731端口号,LoginService服务名
jv9 2010-04-12
  • 打赏
  • 举报
回复
在客户端添加引用后,在ServiceReferences.ClientConfig 中会自动生成绑定信息和EndPoint信息。

你也可以在代码中定义EndPointAddress,可以参考下面的代码:



Dim binding As BasicHttpBinding = New BasicHttpBinding()

Dim address As New EndpointAddress(New Uri(Application.Current.Host.Source, "你的SVC地址"))

Dim client As New DataServiceClient(binding, address)
AddHandler client.GetValuesCompleted, AddressOf client_GetValuesCompleted
client.GetValuesAsync(ID)
...
wkun610 2010-04-12
  • 打赏
  • 举报
回复
能详细点吗?
我调用的是web service
我不知道在哪写后台代码,以及写什么...
谢谢!!
TimDavid 2010-04-12
  • 打赏
  • 举报
回复
想动态
那就只能用后台代码编程咯
WCF也支持后台代码。
xingjunli 2010-04-12
  • 打赏
  • 举报
回复
用RAR解压XAP包 修改ServiceReferences.ClientConfig 配置即可

8,737

社区成员

发帖
与我相关
我的任务
社区描述
WPF/Silverlight相关讨论
社区管理员
  • WPF/Silverlight社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧