Tutorial: How to host a WCF service on DASP

Discussion in 'ASP.NET / ASP.NET Core' started by rdlecler, Apr 9, 2009.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I've had trouble figuring out WCF services and even more trouble getting this hosted on DASP. I really feel that DASP should have taken the initiative and put such tutorials up themselves, but in the absence I have prepared one which shows how to build a bare bones WCF and then I sow you exactly how to publish it to your site hosted on discountasp.net. I also attached the the code. You will need to configure web.config to set the address of your website.

    Most of the this I got service I got from these 4 (amazing) PluralSight video-casts:
    Creating WCF Service (Part 1)
    Creating WCF Client (Part 2)
    Configuring Services with EndPoints (Part 3)
    Hosting WCF Services in IIS (Part 4)

    If you follow those then the only changes you need to make at the end are to the web.config file. I'll post mine below although I use slightly different names to better help me distinguish between which class is which.

    ==========================
    Contents:
    ==========================
    Section 1: Over view of steps
    Section 2: My Configuration and assumptions
    Section 3: Detailed step-by-step process
    Section 4: The set of code snippets you should have
    Section 5: My Web.config


    ==========================
    Section 1: Over view of steps
    ==========================
    ////Part I (Setting Up the service in VS2008)
    1-2: Create the service Library Project
    3-4: Create the Data object which will be passed through your WCF service
    5: Create a service CONTRACT used by the client to INTERFACE with the service implementation
    7-8: Implement the methods specified in the service CONTRACT
    9: Set up the serviceModel for the service
    10: Specify what protocol will be used to interact with the service (ie: basicHttpBinding, wsHttpBinding...)
    11: Specify the endpoint address for the service discovery (mexHttpBinding)
    12-13: Test local access to the service using Visual Studio's "WcfTestClient.exe" util.

    /////Part II (Setting Up the service to be hosted on DASP)
    14: Create a WCFService Website that will be published on discountasp.net
    15: Set up your .svc service that you can point to in your browser. (**Don't forget to remove the "code behind" in the .svc**)
    16: Copy the files created in your Servicelibrary to the WebSiteService project
    17: Remove everything from web.config that is not needed to run our service. (**Dont forget to add in the base address to your dasp website**)
    18: Set the binding to basicHttpBinding (Not sure if wsHttpBinding also works)
    19: Copy the website folder and all of its contents to your discoutasp.net root directory
    20: Make your application service directory an application in DASP the host panel.
    21: Disable basic authentication using the IIS7.0 application tool (**I don't know if you can do it without IIS7??**)
    22: Test remote access to the service using Visual Studio's "WcfTestClient.exe" util.

    ==================================
    Section 2: My Configuration and assumptions
    ==================================
    1) VisualStudio=2008(SP1)
    -VSRoot="C:\Program Files\Microsoft Visual Studio 9.0"
    2) .NET=3.5(SP1)
    3) discountasp.net's Web server=IIS7.0
    4) OS=WindowsXP
    5) Project Root: C:\
    6) Project Name: EvalServiceLibrary
    7) Using IIS7.0 Manager

    ===============================
    Section 3: Detailed step-by-step process
    ===============================
    1) Open V2008. Select: File->New->Project
    -Select: Project types="Visual C#"->"WCF"
    -Select: Templates="WCF ServiceLibrary"
    -Set: Name="EvalServiceLibrary"
    -Set: Location="C:\"
    -CheckBox: Create directory for solution=true
    -Set: Solution Name="EvalServiceLibrary"
    -Select: "Okay"
    2) In "SolutionExplorer": Delete files {IService1.cs, Service1.cs}
    //We will create our own

    3) In "Solution Explorer" RightClick on Solution "EvalService Library"
    -Select: "Add New Item"
    -Select: Categories="Visual C# Items"
    -Select: Templated="Class"
    -Set: Name="EvalDataObject.cs"
    -Select: "Okay"
    4) In "EvalDataObject.cs" code window delete all, replace with the following
    -Copy and Paste Code Section: EvalDataObject.cs (See Code below)


    5) In "Solution Explorer" RightClick on Solution "EvalServiceLibrary"
    -Select: "Add New Item"
    -Select: Categories="Visual C# Items"
    -Select: Templated="Interface"
    -Set: Name="IEvalServiceInterfaceContract.cs"
    -Select: "Okay"
    6) In "IEvalServiceInterfaceContract.cs" code window:
    -Delete all code.
    -Copy and Paste Code Section: IEvalServiceInterfaceContract.cs (See Code below)

    7) In "Solution Explorer" RightClick on Solution "EvalService Library"
    -Select: "Add New Item"
    -Select: Categories="Visual C# Items"
    -Select: Templated="Class"
    -Set: Name="EvalServiceImplementationOfContract.cs"
    -Select: "Okay"

    8) In "EvalServiceImplementationOfContract.cs" code window:
    -Delete all code.
    -Copy and Paste Code Section: "EvalServiceImplementationOfContract.cs" (See Code below)

    9) In "Solution Explorer" under "EvalService Library"
    -RightClick on: App.config
    -Select: "Edit WCF Configuration"
    -In "Configuration Tree"
    -Select: "Services"->"EvalServiceLibrary.Service1"
    -In "Service: EvalServiceLibrary.Service1" "Tree
    -Click on "General"->"Name" field
    -Open Dialog Box in "Name" Field
    -Navigate to: bin\Debug
    -DoubleClickOn: EvalServiceLibrary.dll
    -Select: EvalServiceLibrary.EvalServiceImplementationOfContract
    -Select: "OK"

    10) Still in the in the "WCF Cofiguration" Dialoge:
    -Select: "EvalServiceLibrary.EvalServiceImplementationOfContract"->"EndPoints"
    -Select first "(Empty Name)" in tree menu
    -In "Service Endpoint" menu:
    -Select: Endpoint Properties
    -Click on address text field
    -Set Address="ws"
    -Double Click on "Contract" Field
    -Navigate to: bin\Debug
    -DoubleClickOn: EvalServiceLibrary.dll
    -Select: EvalServiceLibrary.EvalServiceImplementationOfContract

    11) Still in the in the "WCF Cofiguration"
    -Select the second "(Empty Name)" in tree menu
    -In the "Service Endpoint" menu:
    -Select: Endpoint Properties
    -Click on address text field
    -Set Address="mex"

    12) Close "WCF Configuration" and accept save changes
    -Rebuild
    -Select "F5" to run the "WCF Test Client"

    13) When "WCF Test Client" Dialogue pops up
    -DoubleClick->"SubmitEval()" in Tee menue
    -Set: Comments="My Comments"
    -Set: Submitted="Me"
    -Click: "Invoke" Button.
    -Select: "GetEvals()"
    -Click: "Invoke" Button.
    -Observe the data you submitted and retrieved from your service.
    -Stop running (Debig->

    14) In main workbench select "File"->"Add New Web Site"
    -Select Template="WCF Service"
    -Set Filename="C:\EvalServiceWebSite"
    -Set Language="Visual C#"
    -Click "Okay"

    15) Go to "Solution Explorer" under "C:\EvalServiceWebSite"->App_Code
    -Delete {IService.cs, Service.cs}
    -Select: Service.svc
    -Rename: Service.svc -> EvalNetService
    -RightClick on "EvalNetService.svc"->"View In Markup"
    -Delete all code.
    -Copy and Paste Code Section: EvalService.svc (See Code below)
    -Rebuild

    16) Go to "Solution Explorer" under
    -RightClick on "C:\EvalServiceWebSite"
    -Select: "Add Reference"->(Tab)"Projects"->"EvalServiceLibrary"
    //This copies the .dll and EvalServiceLibrary.pbd to your website


    16) In "Solution Explorer" under "EvalServiceLibrary"->"C:\EvalServiceWebSite"
    -RightClick on: Web.onfig
    -Select: "Edit WCF Configuration"
    -In "Configuration Tree"
    -Select: "Services"->"Service"
    -In "Service: EvalServiceLibrary.Service1" "Tree
    -Click on "General"->"Name" field
    -Open Dialog Box in "Name" Field
    -Navigate to: "C:\EvalServiceLibrary\bin\Debug" in Library Directory
    -DoubleClickOn: EvalServiceLibrary.dll
    -Select: EvalServiceLibrary.EvalServiceImplementationOfContract
    -Select: "OK"

    17) Go to the web.config text editor.
    -Delete everything not within the <configuration><system.ServiceModel> tags
    -Delete the "<host>" tags and their contents (If there is one)
    -Delete the "<identity><dns value="localhost"/></identity>
    -Within the <configuration><system.ServiceModel>
    -Copy and Paste Code Section: "serviceHostingEnvironment" (See Code below)


    18) Go back to web.config "WCF Configuration" editor
    -Select: Services->EvalServiceLibrary.EvalServiceImplementationOFContract->Endpoints
    -For wsHttpBinding
    -Set: Address="basic"
    -Set: binding="basicHttpBinding"
    -Click on "Name" field & Open Dialog Box
    -Navigate to: "c:\evalservicewebsite\Bin" in website service Directory
    -DoubleClickOn: EvalServiceLibrary.dll
    -Select: "EvalServiceLibrary.IEvalServiceInterfaceContract"
    -Select: "OK"

    19) Open up FTP and login to your discount.asp site
    -Drag and drop "c:\EvalServiceWebSite" to your base FTP directory.


    20) Login to discount.asp.net's "Hosting Control Panel"
    -Select: Tools&Utilities->Web Application Tool
    -In tree menue select: "EvalServiceWebSite"
    -Click the Add Application button.
    -Go to Tools&Utilities->IIS Tools
    -Restart WebServer.

    21) Start the IIS 7.0 Manager on your computer
    -Connect to your webserver
    -Click on your root directory
    -Select "Authentication"
    -RightRightClick on "Basic" and "disable" authentication

    22) Point browser to: "http://yourdomainname.com/EvalServiceWebSite/EvalService.svc"
    -Ensure you have a page which asks you to create a client with svcutil.exe
    -Go to you Visual Studio's instalation directoy
    -Search for "WcfTestClient.exe"
    -Open command line and run "wcfTestClient.exe http://yourdomain.com/EvalServiceWebSite/EvalService.svc"
     

    Attached Files:

  2. (I also attached this as a text file since the tab formatting has been lost here)

    =======================================
    Section 4: The set of code snippets you should have
    =======================================
    ////START: EvalDataObject.cs
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Runtime.Serialization;

    namespace EvalServiceLibrary
    {
    [DataContract]
    class EvalDataObject
    {
    [DataMember]
    public string Id;
    [DataMember]
    public string Submitter;
    [DataMember]
    public string Comments;
    [DataMember]
    public DateTime TimeSubmitted;
    }
    }
    ////END: EvalDataObject.cs



    //START: IEvalServiceInterfaceContract.cs
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.ServiceModel;

    namespace EvalServiceLibrary
    {
    [ServiceContract]
    interface IEvalServiceInterfaceContract
    {
    [OperationContract]
    void SubmitEval(EvalDataObject eval);
    [OperationContract]
    List<EvalDataObject> GetEvals();
    [OperationContract]
    void RemoveEval(string id);
    }
    }
    //END: IEvalServiceInterfaceContract.cs





    ////START: EvalServiceImplementationOfContract.cs
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.ServiceModel;

    namespace EvalServiceLibrary
    {
    //Only a single list of service created at runtime
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]

    class EvalServiceImplementationOfContract : IEvalServiceInterfaceContract
    {
    List<EvalDataObject> evals = new List<EvalDataObject>();
    #region IEvalServiceInterfaceContract Members

    public void SubmitEval(EvalDataObject eval)
    {
    eval.Id = Guid.NewGuid().ToString();
    evals.Add(eval);
    }

    public List<EvalDataObject> GetEvals()
    {
    return evals;
    }

    public void RemoveEval(string id)
    {
    evals.Remove(evals.Find(e => e.Id.Equals(id)));
    }

    #endregion
    }
    }
    ////END: EvalServiceImplementationOfContract.cs


    ////START: EvalService.svc
    <%@ ServiceHost Language="C#" Debug="true" Service="EvalServiceLibrary.EvalServiceImplementationOfContract"%>
    ////END: EvalService.svc


    ////START: serviceHostingEnvironment
    <serviceHostingEnvironment>
    <baseAddressPrefixFilters>
    <add prefix="http://wagnerlab.com" />
    </baseAddressPrefixFilters>
    </serviceHostingEnvironment>
    ////END: serviceHostingEnvironment

    =====================================
    Section 5: My Web.config
    =====================================
    <?xml version="1.0"?>
    <configuration>
    <system.serviceModel>
    <services>
    <service behaviorConfiguration="ServiceBehavior" name="EvalServiceLibrary.EvalServiceImplementationOfContract">
    <endpoint address="basic" binding="basicHttpBinding" bindingConfiguration=""
    contract="EvalServiceLibrary.IEvalServiceInterfaceContract" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    </service>
    </services>
    <serviceHostingEnvironment>
    <baseAddressPrefixFilters>
    <add prefix="http://yourdomain.com" />
    </baseAddressPrefixFilters>
    </serviceHostingEnvironment>
    <behaviors>
    <serviceBehaviors>
    <behavior name="ServiceBehavior">
    <serviceMetadata httpGetEnabled="true"/>
    <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
    </serviceBehaviors>
    </behaviors>
    </system.serviceModel>
    </configuration>
     

    Attached Files:

  3. **** Warning: I am seeing some spaces inserted where they are not supposed to be. For example in:

    "Service="EvalServiceLibrary.EvalServiceImplementat ionOfContract"

    It's probably best to use the text file for any cut-and-past operations.
     
  4. This looks to be extremely useful and exactly what I needed. Thank you!
    I must compliment you on your thorough attention to detail.

    I downloaded the attached EvalServiceLibrary.zip but it seems to be corrupted.
    Has anyone else tried it?

    Regards, Art

    Update:

    I just discovered that while I cannot open the Zip file using WinZip, I can open and extract the files using 7-Zip.
     
  5. Long, but Very Useful

    Excellent article!
    There were a lot of steps, so I was hesitant at first.
    Also, there was a little bit of ambiguity, but after watching the videos, it was very clear, and I was able to use what I learned to fix my problem.

    Thanks!
     
  6. Excellent tutorial. Keep in mind that web services come in three forms: WCF SOAP, REST (also WCF now), and Asmx Web Services. This tutorial covers the first, should work on the second, and the third is very easy and does not need this tutorial—you just “publish” from within Visual Studio 2008 onto DASP and you’re done, after blessing it with the DASP Web Application Tool (found here: https://my.discountasp.net/webapplication-tool.aspx)

    A couple of comments: to really get good at this, you should do a couple of test projects—and it will take several hours at least, probably more like a whole day as for me, before you become comfortable doing this process manually, following this tutorial. If you don’t want to spend several hours learning the procedure (since likely it will change in Visual Studio 2010 anyway), you can simply download the .zip file from this tutorial and use it as a template—this also works, and you can change a lot of project names so you’re not limited to the names in the tutorial. However, I like to do it from scratch, and I modified this tutorial slightly by following it while using the HowTo found here: http://blog.mstern.at/index.php?/ar...eb-service-in-C-using-Visual-Studio-2008.html (the German Blog). I found the screenshots more helpful at the German Blog.

    An important part of this tutorial, IMO, is the protocol for uploading: after you “disable basic authentication”, using Disable basic authentication using the IIS7.0 application tool (that you download from Microsoft—and you only have to do this to your Discount ASP website URL once for all your projects BTW—it remains persistent—click on the icon in the tool showing a person in profile after you log onto your website from within the tool), you have to follow this protocol: (1) upload the ‘web’ part (new website) of your solution, which are these three components, all within a folder of your choice (i.e., “myFolderName”) that you will FTP upload onto your DASP website: the web.config file (a most important file! if this is wrong the whole project will not work), the .svc file (one liner, follow the tutorial), and the myFolderName/bin folder within the folder of your choice having two files: a .pdb and a .dll file, for example using the German Blog example named: SampleService.pdb and SampleService.dll

    Then run, in this order, the DASP Web Application Tool mentioned above, and then STOP/START your website using the DASP IIS7 web tool found here: https://my.discountasp.net/web-manager/iis7-stopstart.aspx

    After uploading and doing the above, you then know if your WCF web service works by cutting and pasting this line into your browser, say Internet Explorer, assuming your DASP website URL is something like http://JoeBlow.web777.discountasp.net [or it can be http://mycompany.com if DASP is hosting your company]: http://JoeBlow.web777.discountasp.net/myFolderName/SampleService.svc

    if you WCF web service works, you’ll know it, since it will not give an error, and say something like this: “You have created a service. To test this service, you will need to create a client and use it to call the service. You can do this using the svcutil.exe tool from the command line with the following syntax: …”
    Then write a web service client in a separate application such as shown in the German Blog.
    One final thing: the most important part of the web.config file is to get rid of the stuff that was in the app.config file, as suggested in this tutorial, and replace it with the section having XML attribute: <serviceHostingEnvironment>. The second important thing is to add endpoints, which you can do ‘manually’ as taught in the tutorial, or using a tool found in Visual Studio 2008. There are two endpoints (at least) in any such project, the first being the Mex endpoint which is generated automatically when you debug and you should not play with it, and the second endpoint, you either change manually as suggested by the tutorial here, or, what I did (based on the Channel 9 videos that the tutorial here references), is to right-click onto the web.config file and then selected “Edit WCF Configuration” (which brings up a wizard that is external to Visual Studio) then delete the non-Mex endpoint, add an endpoint having the standard Address-Binding-Contract protocol (see the Channel 9 videos), and Address should be: ‘basic’, Binding should be: ‘basicHttpBinding’ and the Contract is found by clicking on the .dll that you built for your web service—but be careful here, as it’s tricky if you have several versions (!)—find the latest one, in the /bin folder, of the project you are interested in. If you have several versions and are not paying careful attention, Visual Studio, when you create new projects, keeps the old or previous default project/folder name and without being aware of it you could be working with an old .dll (and if you’ve changed the service you’ll wonder why the old service methods keep showing up). If you don’t like using this external tool, then stick to the ‘manual’ way suggested by the tutorial.

    Here I will leave you with “before” and “after” samples of a web.config file, showing the all important changes made:

    //
    BEFORE (this web.config file will not work for an uploaded web service in WCF you plan to host on DASP; it will only work for localhost debugging):
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
    <system.web>
    <compilation debug="true" />
    </system.web>
    <!-- When deploying the service library project, the content of the config file must be added to the host's
    app.config file. System.Configuration does not support config files for libraries. -->
    <system.serviceModel>
    <services>
    <service behaviorConfiguration="SampleService.Service1Behavior"
    name="SampleService.Service1">
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <endpoint address="basic" binding="basicHttpBinding" contract="SampleService.IService1" />
    <host>
    <baseAddresses>
    <add baseAddress="http://localhost:8733/Design_Time_Addresses/SampleService/Service1/" />
    </baseAddresses>
    </host>
    </service>
    </services>
    <behaviors>
    <serviceBehaviors>
    <behavior name="SampleService.Service1Behavior">
    <!-- 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>


    //
    AFTER (this web.config file will work for an uploaded DASP web service in WCF):
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
    <system.web>
    <compilation debug="true" />
    </system.web>
    <!-- When deploying the service library project, the content of the config file must be added to the host's
    app.config file. System.Configuration does not support config files for libraries. -->
    <system.serviceModel>
    <services>
    <service behaviorConfiguration="SampleService.Service1Behavior"
    name="SampleService.Service1">
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <endpoint address="basic" binding="basicHttpBinding" contract="SampleService.IService1" />

    </service>
    </services>

    <serviceHostingEnvironment>
    <baseAddressPrefixFilters>
    <add prefix="http://JoeBlow.web777.discountasp.net"/>
    </baseAddressPrefixFilters>
    </serviceHostingEnvironment>


    <behaviors>
    <serviceBehaviors>
    <behavior name="SampleService.Service1Behavior">
    <!-- 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>

    :)
     
  7. Hi,

    Does this work the same with VS 2010?


    Thanks,

    Mike
     
  8. Bruce

    Bruce DiscountASP.NET Staff

    are you using asp.net 4.0 or 2.0?
     
  9. Hi,

    ASP.NET 4.0 on VS 2010.

    Thanks,

    Mike
     
  10. This protocol does not work with REST easily

    This protocol works fine for SOAP messages, but, for REST messages, not so fine. I am finding this out the hard way, see here for more details:

    http://tinyurl.com/38qj6z8

    and

    http://tinyurl.com/37uvzal

    As best I can tell at the moment, the problem with REST is that the app.config file keeps being told the service is SOAP , if you follow the protocol in this thread, rather than a REST web service, even if you set up your contract as REST (using for example WebServiceHost for your host class)


    Pat
     
  11. ...I'm not saving the RSS feeds for this but there have been a bunch of posts related to this in the MSDN blogs over the past few weeks.
    You guys might want to search there for some tips.
    ...Just saying ;-)
     
  12. Does not work for Visual Studio 2010 Express edition

    For Visual Studio 2010 Express Edition, as of this moment (June 2010), the protocol in this thread does not work, because there is no "add Empty Web Site" as shown in the screenshot in this blog: http://blog.mstern.at/index.php?/ar...eb-service-in-C-using-Visual-Studio-2008.html

    However, I'm sure a later release will fix this, or somebody will figure out how to add a template for this. As for me, I'm sticking for now to Visual Studio 2008, where I can make things work for WCF SOAP web services following the protocol in this thread.

    :)
     
  13. OK it *does* work with Visual Studio 2010

    UPDATE: Visual Studio 2010 has a different look than VS2008--so I'm not so sure about whether it will work even after you do the below....for example the .SVC file and the web.config files have extra files added to them...so I spoke too soon!

    OK I figured out, without having to do a "repair" or "reinstall" how to get the protocol in this thread to work for Visual Studio 2010. I'm very confident this will work, even though I have not tried it. If it does not work, I'll post here. All you have to do is open up the "Microsoft Visual Web Developer 2010 Express", click on the WCF Service Application, follow the "German blog" in this thread (http://blog.mstern.at/index.php?/ar...eb-service-in-C-using-Visual-Studio-2008.html) but when it gets time for a "New Web Site" you cannot do it by right-clicking (as in Visual Studio 2008), but you must start another instantiation of VS2010, then pick "New Project" and "Empty Web Application", then you are set, just right click on the project and follow where the German blog says "The web site is added. Now add a reference to our previously created web service ...". Of course you have to also follow this thread for the remote web server hosting stuff, in particular the web.config file

    This should work, and I'll do a test of it later today or tomorrow...(UPDATE: may not work as planned...)

    PJ
     
  14. ...Thanks for the update ;-)
     
  15. No problem

    I have various theories on how to make it work for Visual Studio 2010, but rather than clog up this thread I'll leave it for somebody else to describe (hint: it's all about the web.config file)...for now I'm sticking to VS 2008, using this protocol, and it works great. As for REST, you can also more or less follow this protocol, but if you check out the links I posted earlier in this thread, linking to MSDN, you'll find the web.config file in REST is not as important...actually very unimportant it seems...as I got REST to work with a variety of web.config files, once you pick the right binding (use webHttpBinding for REST, address can be "").
     
  16. Protocol for remote database and web services

    I wrote a program for Silverlight that uses web services to run SQL Server, from a online article by Jesse Liberty: http://www.silverlight.net/learn/tutorials/sqldatagrid-cs/. In the article he runs his web services locally, using local host, but I ran SQL Server on DASP, and the web services there too.

    There are various pitfalls to avoid if you want to run things remotely, as I did, but one thing I want to caution anybody reading this thread: for Visual Studio 2008 make sure you don't use a local database and then try to publish it to DASP--instead, what worked for me, was to connect to the database after you follow this thread (http://support.discountasp.net/KB/a188/sql-2008-management-tools.aspx), from inside of Visual Studio, using a SQL Server authentication rather than the default Windows Authentication (following this thread: https://support.discountasp.net/KB/a186/how-to-connect-to-sql-server-2008-using-sql-server.aspx), and thereby insuring all your connectionstrings are proper (as emphasized by this thread: http://community.discountasp.net/showthread.php?p=37203#post37203). What I tried to do, and failed initially, until I did the above, was run the database locally (on localhost) from inside VS2008, them publish a web service as per this thread after changing the connection strings manually. This did not work. Instead, what worked was to build your Visual Studio project as per the Jesse Liberty article from the database you first upload to DASP, then follow this thread to publish the web services (which comprise three files: a .svc text files and two library files .dll and .pdb). After you do that, the project worked fine. It also helps to have a file in your DASP root directory labeled:

    clientaccesspolicy.xml

    and containing:

    <?xml version="1.0" encoding="utf-8" ?>
    - <access-policy>
    - <cross-domain-access>
    - <policy>
    - <allow-from http-request-headers="*">
    <domain uri="*" />
    </allow-from>
    - <grant-to>
    <resource path="/" include-subpaths="true" />
    </grant-to>
    </policy>
    </cross-domain-access>
    </access-policy>

    :)
     
  17. ...Good stuff. ;-)
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page