以编程方式创建WCF客户端

eid*_*lon 11 wcf-client type-mismatch

我有一个支持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)
Run Code Online (Sandbox Code Playgroud)

但是当我调用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'.."}
Run Code Online (Sandbox Code Playgroud)

如何正确创建我的客户端,以便这些正确"匹配"?
提前致谢!!!

eid*_*lon 11

啊---找到了.该ServiceModel在网站的部分web.config设置为customBinding.更改它以使其与客户端发送的内容相匹配,现在它的工作效果非常好.