troubleshooting Question

Web.config made automatically according to WCF service

Avatar of panJames
panJames asked on
.NET ProgrammingC#
3 Comments1 Solution249 ViewsLast Modified:
Hello experts!

I am trying to get my head around example I found on internet.

I am trying to re- create the example of simple service I found on internet.

This is what I do:

1. VS2005 Pro -> new project -> class library

2. I have three files my service consists from:


A.

*** DataContract.cs***


using System;
using System.Collections.Generic;
using System.Runtime.Serialization;

namespace SampleService
{
    [DataContract]
    public class Request
    {
        string name;

        [DataMember]
        public string Name
        {
            get { return name; }
            set { name = value; }
        }
    }

    [DataContract]
    public class Response
    {
        string message;

        [DataMember]
        public string Message
        {
            get { return message; }
            set { message = value; }
        }
    }

}


B.

***Service.cs***

using System;
using System.Collections.Generic;
using System.ServiceModel;

namespace SampleService
{
    [ServiceBehavior]
    public class Service: ISampleService
    {
        [OperationBehavior]
        public Response GetMessage
            (
            Request request
            )
        {

            Response response = new Response();

            if ( null == request )
            {
                response.Message = "Error!";
            }
            else
            {
                //set the message
                response.Message = "Hello, " + request.Name;
            }

            return response;
        }

        [OperationBehavior]
        public string SayHello()
        {
            return "Hello, World!";
        }
    }
}

C.

***ServiceContract.cs***

using System;
using System.ServiceModel;

namespace SampleService
{
    [ServiceContract]
    public interface ISampleService
    {
        [OperationContract]
        Response GetMessage
            (
            Request request
            );

        [OperationContract]
        string SayHello();
    }
}

I understand that I need service.svc file, so I have it:

***Service.svc***

<% @ServiceHost
            Language=C#
            Service="SampleService.Service"
%>



Questions:


1. How can I configure VS to create Web.Config file automatically when I build my service and put it into selected folder?

Thank you

panJames




Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros