问题
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