简体   繁体   English

在Internet配置上公开WCF Web服务

[英]Expose WCF Web service on the internet configuration

I am trying to expose a webservice written in WCF, to the open internet but i am having trouble configuring it to be consumed from the external url. 我试图将用WCF编写的Web服务公开给开放的Internet,但是我无法配置它以从外部URL使用。

The web service is hosted internally at https://ourportal.internaldomain.intra:9011/FrontEndWS and works well. 该Web服务内部托管在https://ourportal.internaldomain.intra:9011 / FrontEndWS上,并且运行良好。 We have exposed the webservice on https://www.internetdomain.com.mt/FrontEndWS however when accessing it from the external address, the soap URLs still referer to the internal address. 我们已经在https://www.internetdomain.com.mt/FrontEndWS上公开了该Web服务,但是当从外部地址访问该Web服务时,Soap URL仍然引用内部地址。

Our settings are as follows. 我们的设置如下。 We do not need to expose the webservice internally, only on the internet so this should simplify configuration. 我们不需要内部公开Web服务,而只需要在Internet上公开,这样可以简化配置。

<bindings>
 <basicHttpBinding>
   <binding name="LargeMessagingBinding" maxBufferSize="99999900" maxBufferPoolSize="524288000" maxReceivedMessageSize="99999900">
     <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="99999900" maxBytesPerRead="99999900" maxNameTableCharCount="2147483647" />
     <security>
       <transport clientCredentialType="Basic" />
     </security>
   </binding>
 </basicHttpBinding>
</bindings>
<behaviors>
 <serviceBehaviors>
   <behavior name="ServiceBehaviour">
     <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"  />
     <serviceDebug includeExceptionDetailInFaults="true" />
     <dataContractSerializer maxItemsInObjectGraph="6553600" />
   </behavior>
 </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="false" />

In order to expose your web service to the external world, you would have the WCF service in a Virtual directory under a website in IIS. 为了将您的Web服务公开给外部世界,您需要将WCF服务放在IIS中网站下的虚拟目录中。

Now your url " www.internetdomain.com.nt " would be mapped to a specific IP address (externally accessible) and this IP address is the IP addresss of your server on which the WCF service is exposed. 现在,您的URL“ www.internetdomain.com.nt ”将被映射到特定的IP地址(可外部访问),并且此IP地址是WCF服务所在的服务器的IP地址。

Any request on this IP is received by IIS and determines on how to serve the request. IIS收到此IP上的任何请求,并确定如何处理该请求。

If the above is fine then the URL for your WCF service would be: 如果以上情况都很好,那么您的WCF服务的URL将是:

http://www.internetdomain.com.nt/virtualdirectory/FrontEndWS
https://www.internetdomain.com.nt/virtualdirectory/FrontEndWS

For the https case your website would have the 443 https port mapped via Edit Bindings option and specifies the service certificate it needs to use. 对于https情况,您的网站将通过“ Edit Bindings选项映射443 https端口,并指定它需要使用的服务证书。

Also you need to define your service with an endpoint in the web.config. 另外,您还需要在web.config中使用端点定义服务。 Example shown below: 示例如下所示:

<bindings>
 <basicHttpBinding>
   <binding name="LargeMessagingBinding" maxBufferSize="99999900" maxBufferPoolSize="524288000" maxReceivedMessageSize="99999900">
     <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="99999900" maxBytesPerRead="99999900" maxNameTableCharCount="2147483647" />
     <security>
       <transport clientCredentialType="Basic" />
     </security>
   </binding>
 </basicHttpBinding>
</bindings>
<services>
      <service name="SampleWCFService.Service1" behaviorConfiguration="default">
        <endpoint address="" behaviorConfiguration="ServiceBehaviour" binding="basicHttpBinding" bindingConfiguration="LargeMessageBinding" contract="SampleWCFService.IService1"/>
      </service>
</services>
<behaviors>
 <serviceBehaviors>
   <behavior name="ServiceBehaviour">
     <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"  />
     <serviceDebug includeExceptionDetailInFaults="true" />
     <dataContractSerializer maxItemsInObjectGraph="6553600" />
   </behavior>
 </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="false" />

Check the services element in the above configuration. 检查以上配置中的services元素。 Make sure that the namespace of the service is specified correctly. 确保正确指定了服务的名称空间。

I had the same problem and now figured out that it was because of the SSL offloader which was infront of the web server. 我遇到了同样的问题,现在发现这是由于Web服务器前端的SSL卸载程序。 Check with your admin group. 请与您的管理员组联系。 We got rid of SSL offloader as we had to make the service up. 我们摆脱了SSL卸载程序,因为我们不得不补充服务。 You can refer to the links below 您可以参考以下链接

http://blogs.msdn.com/b/distributedservices/archive/2010/06/01/ssl-offloader-using-wcf-4-0-routing-service.aspx http://blogs.msdn.com/b/distributedservices/archive/2010/06/01/ssl-offloader-using-wcf-4-0-routing-service.aspx

http://blogs.msdn.com/b/distributedservices/archive/2010/05/13/wcf-and-intermediate-devices.aspx http://blogs.msdn.com/b/distributedservices/archive/2010/05/13/wcf-and-intermediate-devices.aspx

Also add host header for https 同时添加https的主机头

http://www.sslshopper.com/article-ssl-host-headers-in-iis-7.html http://www.sslshopper.com/article-ssl-host-headers-in-iis-7.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM