You are on page 1of 6

To deploy a service to IIS7.5 (from VS2008 Project .net 3.5): 1. Run cmd.

exe (in administrative privs) and locate the following C:\Windows\Microsoft.NET\Framework\V4.0.30319\aspnet_regiis.exe i The (-i) switch is used to install ASP.net 4 to IIS Application Pool Selection

2. Use VS2008/10, create new , website project, then create a WCFService. VS should look like the following(this includes the created clientaccesspolicy.xml from the installed code snippet (example below);

The clientaccesspolicy.xml file is required in the project as the client will be browsing using internet explorer (or browsing software) and will therefore be on a different domain. By tracing HTML packets using Dev tools (F12 in I.E9) it can be seen that before any service data exchange begins for the first time by the client, the browser tries to do one of two things: Obtain the clientaccesspolicy.xml to see if its allowed entry to this cross domain service If the above file cannot be found, the browser tries to access a crossdomain.xml policy file (generated by Adobe Systems) which does pretty much the same thing as the first file (apart from this one must be used if flash is involved) NOTE The above 2 files (or clientaccesspolicy.xml in this case) must be placed at the root of http://[IPADDRESS]:80/ (not the port the service is hosted on). If these files are missing, the client will be refused access to the service. It is often not a programmers issue to deal with the crossdomain.xml/clientaccesspolicy.xml but more the webhosters service, and usually they will provide these files.

3. Edit or add classes/functions to the APPCODE\Service.cs (dont forget to add service functions to the Iservice.cs Service Class Interface) 4. Edit the web.config (renaming the service endpoint-address binding to basicHttpBinding and the Iservice interface address to mex and mexHttpBinding) (See copy of web.config ready for deployment at the end of this document); 5. Publish the service (by right clicking on project in solution explorer) to a desired folder. Once a precompiled web folder is created, copy this folder to the C:\ or main disk drive and rename it accordingly. 6. Right click on this new folder, go properties, then security. The user group IIS-IUSR needs to be given read permissions to this folder and all of the files contained inside it. 7. Now copy the clientaccesspolicy.xml file to the folder where port 80 talks to (usually the Default Website Folder where IIS stores its dafault webpage (C:\inetpub\wwwroot). 8. Open IIS, and expand sites, right click sites and click Add Add Website:

9. Fill in form as below:

Site Name = Anything, just something that ties up with the project Select Application pool = ASP.NET v4.0 Physical Path = Root folder of the service on C:\ (done in step 5). Type=Http IPAddress=IP of Hosting Server/PC Port= Any port you like, but if the developer has built this project on a specific port, best to use that one (as that is what the client will look for) Then click OK. 10. Edit the default document for this website to the *.svc file in the root of the service (unless the developer has created a specific landing page if clients accidently navigate to this), as this will show an auto generated website showing that the files in the root of the service are readily available to access by clients. 11. Go into Authentication of the website, select Anonymous Authentication and enable it (if it isnt all ready), then click Edit in actions pane, and select User Identity as Application Pool Identity (not a specific user)

That should be it, the service should be hosting on http://[IPADR]:[PORT]/Service.svc. This URL can be added into ServiceReferences URL when in VS2008. Browsing to this should show the Service in a webpage. (like below)

Web.config (modified and ready for deployment)


<?xml version="1.0"?> <configuration> <system.web> <!-Set compilation debug="true" to insert debugging symbols into the compiled page. Because this affects performance, set this value to true only during development. --> <compilation debug="false"> <assemblies> <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> </assemblies> </compilation> <!-The <authentication> section enables configuration of the security authentication mode used by ASP.NET to identify an incoming user. --> <authentication mode="Windows" />

<pages> <controls> <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> </controls> </pages> <httpHandlers> <remove verb="*" path="*.asmx"/> <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/> </httpHandlers> <httpModules> <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> </httpModules> </system.web> <system.codedom> <compilers> <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <providerOption name="CompilerVersion" value="v3.5"/> <providerOption name="WarnAsError" value="false"/> </compiler> <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <providerOption name="CompilerVersion" value="v3.5"/> <providerOption name="OptionInfer" value="true"/> <providerOption name="WarnAsError" value="false"/> </compiler> </compilers> </system.codedom> <!-- This is the important part --> <system.serviceModel> <services> <service name="Service" behaviorConfiguration="ServiceBehavior"> <!-- Service Endpoints --> <endpoint address="" binding="basicHttpBinding" contract="IService"/> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> </service>

</services> <behaviors> <serviceBehaviors> <behavior name="ServiceBehavior"> <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> <serviceMetadata httpGetEnabled="true"/> <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> <serviceDebug includeExceptionDetailInFaults="false"/> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel> </configuration>

You might also like