2010-05-25 35 views
3

我已經從我的silverlight應用程序向我的本地開發服務器提供了服務引用。 但現在我想部署在測試服務器上,但我怎麼能改變數據服務器的uri現在呢? 所有我部署的是一個XAP文件,在asp.net世界中,我習慣於改變web.config中的uri,但顯然這並不存在於Silverlight應用程序中?silverlight:部署後將uri更改爲我的數據服務

回答

3

See this answer有關如何以編程方式設置您的WCF代理端點的一些詳細信息。這樣做意味着您可以避免將任何地址信息放入配置文件中。

+0

+1。我可能會誤解這個問題。 – 2010-05-25 10:52:41

+0

是啊!那就是訣竅。 – Michel 2010-05-26 09:17:57

0

您的Silverlight應用程序應將ServiceReferences.ClientConfig合併到您的web.config文件中。您可以在下面找到它:

<system.serviceModel> 
    <bindings> 
     <!-- Your binding details here --> 
    </bindings> 
    <client> 
     <endpoint address="http://localhost/servicename/servicename.svc" 
      binding="basicHttpBinding" 
      bindingConfiguration="BasicHttpBinding_Iservicename" 
      contract="servicenameReference.Iservicename" 
      name="BasicHttpBinding_Iservicename" /> 
    </client> 
</system.serverModel> 

修改地址以指向生產服務器。

+0

但web.config是在我的網站,而不是在客戶端的計算機上,是嗎?那麼Silverlight應用程序在瀏覽器中的XAP文件如何連接到web.config以查看終端地址? – Michel 2010-05-25 10:07:52

+0

正確,web.config位於XAP文件所說的服務器上。 – 2010-05-25 10:10:30

+0

@Ardman,我認爲重點在於Silverlight應用程序尚未確定服務器在哪裏? – slugster 2010-05-25 10:11:48