我有一个在开发中运行良好的WCF Web服务和应用程序。我已经在IIS服务器上发布了WCF,并且能够通过防火墙内的Web应用程序使用它来按服务器名称对其进行寻址。但是,既然我已将它用于外部使用,那就会造成问题。
我的网络应用尝试连接时出错。我可以从防火墙内外看到服务,disco,wsdl等,但是当我第一次从外部调用身份验证时,服务返回DISCO页面而不是处理身份验证方法调用。这会导致ProtocolException,因为据我所知,该应用程序需要xml,而不是html。
同样,完全相同的Web应用程序可以正常地点击IIS服务器。 外部的一个区别是我从网址到达它,在内部我正在使用服务器名称。但是,该服务使用Web地址加载到防火墙外的Web浏览器中。
部分网络应用配置:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding
name="WSHttpBinding_IWebService"
closeTimeout="00:03:00"
openTimeout="00:03:00"
receiveTimeout="00:10:00"
sendTimeout="00:03:00"
bypassProxyOnLocal="false"
transactionFlow="false"
hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="5000000"
maxReceivedMessageSize="5000000"
useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="5000000"
maxArrayLength="5000000"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport
clientCredentialType="Windows"
proxyCredentialType="None"
realm="" />
<message
clientCredentialType="Windows"
negotiateServiceCredential="true"
algorithmSuite="Default"
establishSecurityContext="true"
/>
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://<dns address/server address>/WebService.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IWebService"
contract="WebServiceRef.IWebService" name="WSHttpBinding_IWebService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</client>
部分服务web.config文件:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding
name="ServiceBinding"
openTimeout="00:03:00"
sendTimeout="00:03:00"
transactionFlow="false"
maxBufferPoolSize="5000000"
maxReceivedMessageSize="5000000">
</binding>
</wsHttpBinding>
</bindings>
<services>
<service
behaviorConfiguration="xxx.WebServiceBehavior"
name="xxx.WebService">
<endpoint
address="http://<dns address/server address>/WebService.svc"
binding="wsHttpBinding"
bindingConfiguration="ServiceBinding"
contract="xxx.IWebService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
/WebService.svc"/>