我有一个支持 Silverlight 的 WCF 服务的网站。该服务运行良好,我可以毫无问题地在浏览器中浏览到 WSDL 页面。
现在,我正在尝试在 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'.."}
如何正确创建我的客户,以便这些正确“匹配”?
提前致谢!!!