Dynamic service reference in Silverlight

落花浮王杯 提交于 2019-12-11 17:30:44

问题


I'm building a Silverlight application that interfaces with SharePoint Web Services. In a windows forms application I'd create a web reference to my local SharePoint server, then change the Uri of the reference at runtime to point to whatever SharePoint site I wanted to use. Silverlight doesn't seem to have web references, but similar functionality can be achieved with service references. However, there doesn't seem to be a way to change the Uri of the reference at runtime. Is there a way to do this in Silverlight? Or a better way of using SharePoint web Services from Silverlight?

Note: I need to access list item attachments, so owssvr.dll won't be sufficient (I think?)


回答1:


Seeing as you are using WCF (to reference the Service), you can change the Address of the service like so:

MyServiceSoapClient soapClient = new MyServiceSoapClient();
mySoapClient.Endpoint.Address = new EndpointAddress(URI]);
// do call here 



回答2:


There seems to be alot missing from this example. soapClient vs. mySoapClient? Endpoint.address is not a property of a service (SVC).



来源:https://stackoverflow.com/questions/1047761/dynamic-service-reference-in-silverlight

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!