1

I'm desperately in need of a working example of a WCF 4 RESTful web service. Our SaaS ticketing system (zendesk.com) can communicate with an URL target using HTTP GET, POST or PUT. I have not done any web related work (only c# console apps) but have now been tasked to create a WCF 4 web service with the following requirements:

  1. Secured via HTTPS
  2. Secured via username / password
  3. Read and process the data from the SaaS system that is transmitted as application/x-www-form-urlencoded information, for example:

    http://somedomain/a/path?value=message+with+placeholders+evaluated
    

My current code is as follows:

namespace WcfService2
{
    [ServiceContract]
    public interface IService1
    {
        [OperationContract]
        [WebInvoke]
        void ClearAlert(Stream input);
    }
}

namespace WcfService2
{
    public class Service1 : IService1
    {
        public void ClearAlert(Stream input)
        {
            StreamReader rawTicketData = new StreamReader(input);
            string ticketData = rawTicketData.ReadToEnd();
            rawTicketData.Dispose();
            //Do some work with ticketData
        }
    }
}

The web.config file:

<services>
  <service behaviorConfiguration="MetaDataBehavior" name="WcfService2.Service1">
    <endpoint behaviorConfiguration="RestBehavior" binding="webHttpBinding" bindingConfiguration="" name="REST" contract="WcfService2.IService1" />
  </service>
</services>
<behaviors>
  <endpointBehaviors>
    <behavior name="RestBehavior">
      <webHttp />
    </behavior>
  </endpointBehaviors>
<behaviors>

I am currently using only HTTP (not HTTPS) for development and testing hence the missing binding entry / entries for HTTPS as well as any entries for login purposes in the web.config, at least I assume that is what / where I need to add the needed configuration but again, I have no knowledge.

I would more than appreciate any help / assistance I can get in creating a web service with the three above described requirements.

Thanks to all!

William

4

0 回答 0