简体   繁体   中英

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.

The web service is hosted internally at https://ourportal.internaldomain.intra:9011/FrontEndWS and works well. 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.

Our settings are as follows. We do not need to expose the webservice internally, only on the internet so this should simplify configuration.

<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.

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.

Any request on this IP is received by IIS and determines on how to serve the request.

If the above is fine then the URL for your WCF service would be:

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.

Also you need to define your service with an endpoint in the 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. 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. Check with your admin group. We got rid of SSL offloader as we had to make the service up. 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/05/13/wcf-and-intermediate-devices.aspx

Also add host header for https

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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