我有一個啓用了Silverlight的WCF服務的網站。該服務工作正常,我可以在瀏覽器中瀏覽WSDL頁面,而不會出現任何問題。以編程方式創建WCF客戶端
現在,我想在DLL中創建一個客戶端。我需要以編程方式創建整個客戶端,因爲它是在DLL中調用的,無論出於什麼原因(通過設計?)都不會從它自己的配置文件中讀取ServiceModel節。
因此,這裏是我的代碼:
Dim endp As EndpointAddress = New EndpointAddress("http://www.mydomain.com/licensing/lic.svc")
Dim bind As WSHttpBinding = New WSHttpBinding()
Dim svc = New lnt.licClient(bind, endp)
Dim rsp = svc.CheckIt(key)
但是,當我稱之爲svc.CheckIt方法,我得到以下錯誤:
Content Type application/soap+xml; charset=utf-8 was not supported by service http://www.mydomain.com/licensing/lic.svc.
The client and service bindings may be mismatched.
{"The remote server returned an error: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'application/soap+msbin1'.."}
如何正確地創建我的客戶,使這些是否正確「匹配」?
在此先感謝!
Sivlerlight不支持WSHttpBinding。 http://msdn.microsoft.com/en-us/library/cc896571(VS.95).aspx – 2010-07-28 05:57:44