我使用iis 7.0托管了我的wcf,网址是:
https://example.com/CustPortal/CustomerService.svc
当我在vs2008中添加服务引用时,出现了这样的错误:
The document at the url https://example.com/CustPortal/CustomerService.svc was not recognized as a known document type.
The error message from each known type may help you fix the problem:
- Report from 'DISCO Document' is 'There was an error downloading 'https://el-cust-port01/CustPortal/CustomerService.svc?disco'.'.
- Unable to connect to the remote server
- No connection could be made because the target machine actively refused it 59.37.71.86:443
- Report from 'WSDL Document' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'.
- Report from 'https://193.91.152.191/CustPortal/CustomerService.svc' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'.
- Report from 'XML Schema' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'.
Metadata contains a reference that cannot be resolved: 'https://193.91.152.191/CustPortal/CustomerService.svc'.
Metadata contains a reference that cannot be resolved: 'https://193.91.152.191/CustPortal/CustomerService.svc'.
If the service is defined in the current solution, try building the solution and adding the service reference again.
我的web.config是
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="metadataBehavior">
<serviceMetadata httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceCredentials>
<serviceCertificate storeName="My" x509FindType="FindBySubjectName" findValue="TESTCERT" storeLocation="LocalMachine"/>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="metadataBehavior" name="EV.Services.CustomerService">
<endpoint binding="wsHttpBinding" bindingConfiguration="wsHttpBindingConfig" contract="EV.Contracts.ICustomer" />
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="wsHttpBindingConfig">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>
答案 0 :(得分:4)
我认为您还缺少元数据Excahnge(mex)端点。尝试添加:
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
在现有端点下方。您应该能够打开Web浏览器:
并查看显示的实际WSDL文件。
答案 1 :(得分:0)
你在家里主持吗?该错误基本上表示您无法访问IP地址,我可以。这可能是不支持“nat loopback”的路由器,因此您无法从网络内部访问外部IP地址。尝试通过其本地IP地址添加引用。
答案 2 :(得分:0)
在本地电脑的主机文件(C:\ Windows \ System32 \ drivers \ etc \ hosts)中添加服务器的网络服务主机名和IP地址