Click here to Skip to main content
15,910,603 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: IsUserInRole too slow - ASP.NET Pin
sharp_k9-Feb-12 7:05
sharp_k9-Feb-12 7:05 
GeneralRe: IsUserInRole too slow - ASP.NET Pin
sharp_k9-Feb-12 7:11
sharp_k9-Feb-12 7:11 
GeneralRe: IsUserInRole too slow - ASP.NET Pin
DaveAuld9-Feb-12 7:53
professionalDaveAuld9-Feb-12 7:53 
Generalanswers inside Pin
sharp_k9-Feb-12 8:29
sharp_k9-Feb-12 8:29 
QuestionAbout Gridview Pin
Amit_9-Feb-12 1:56
Amit_9-Feb-12 1:56 
AnswerRe: About Gridview Pin
Abhinav S9-Feb-12 20:38
Abhinav S9-Feb-12 20:38 
QuestionHow to secure a .ASHX-Request? Pin
softwarejaeger8-Feb-12 1:25
softwarejaeger8-Feb-12 1:25 
QuestionWCF Service Pin
Satish_S8-Feb-12 1:22
Satish_S8-Feb-12 1:22 
Hi I have created a WCF service and hosted the service as a windows service, i am able to browse from the browser like
http://localhost:8080/webservices/dataservice.svc?


when i browse i am getting the intro screen saying about svcutil.exe and generating proxies.

i have some 2 methods inside the WCF service and is running as a windows service.when i make a call to the service in order to call and execute the function inside it , i am not getting any reply but always it shows the intro screen with metadata.

How to call the method inside windows service(WCF service as windows service)

method call from browser

http://localhost:8080/webservices/dataservice.svc/GetQuote



procedure created to make wcf as winservice


C#
public class ServiceProjectInstaller:ServiceBase
   {
       public ServiceHost serviceHost = null;

       public ServiceProjectInstaller()
       {
           //Name of the Windows Service.
            ServiceName = "WCFService";
       }

        public static void Main()
        {
            ServiceBase.Run(new ServiceProjectInstaller());
        }
        //Start the Windows Service.
        protected override void OnStart(string[] args)
        {

            TraceWinService("Starting a Service");

            Timer timer = new Timer();
            timer.Elapsed += new ElapsedEventHandler(OnElapsedTime);
            timer.Interval = 60000;
            timer.Enabled = true;


            if (serviceHost != null)
            {
                serviceHost.Close();
            }
            //Create a ServiceHost for the CService type and provide the base address.

            serviceHost=new ServiceHost(typeof(myService.dataService.CDataService));

            // Open the ServiceHostBase to create listeners and start 
            // listening for messages.
            serviceHost.Open();

        }
        private void OnElapsedTime(object source, EventArgs e)
        {
            TraceWinService("Another Event at: " + DateTime.Now);
        }
        protected override void OnStop()
        {
            if (serviceHost != null)
            {
                serviceHost.Close();
                serviceHost = null;
            }
        }
        private void TraceWinService(string content)
        {
            FileStream fs = new FileStream(@"d:\ScheduledService.txt", FileMode.Open, FileAccess.Write);
            StreamWriter sw = new StreamWriter(fs);
            sw.BaseStream.Seek(0, SeekOrigin.End);
            sw.WriteLine(content);
            sw.Flush();
            sw.Close();

        }

        private void InitializeComponent()
        {

        }
 
    }
   // Provide the ProjectInstaller class which allows 
   // the service to be installed by the Installutil.exe tool
   [RunInstaller(true)]
   public class ProjectInstaller : Installer
   {
       private ServiceProcessInstaller process;
       private ServiceInstaller service;

       public ProjectInstaller()
       {
           process = new ServiceProcessInstaller();
           process.Account = ServiceAccount.LocalSystem;
           service = new ServiceInstaller();
           service.ServiceName = "WCFService";
           service.StartType = System.ServiceProcess.ServiceStartMode.Automatic;
           Installers.Add(process);
           Installers.Add(service);
       }
   }



config file


C#
<configuration>
  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="WSHttpBinding_ICDataService" closeTimeout="00:01:00"
          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
          bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
          maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
          textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00"
            enabled="false" />
          <security mode="Message">
            <transport clientCredentialType="Windows" proxyCredentialType="None"
              realm="" />
            <message clientCredentialType="Windows" negotiateServiceCredential="true"
              algorithmSuite="Default" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:8080/WCFService/dataservice.svc"
        binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IClickDataService"
        contract="Dvmwebservices.IClickDataService" name="WSHttpBinding_IClickDataService">
        <identity>
          <servicePrincipalName value="host/ac.sdwe.sw.co.in" />
        </identity>
      </endpoint>
    </client>
    <services>
      <service name="myService.CService.CDataService" behaviorConfiguration="CDataServiceBehavior">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8080/WCFService/dataservice.svc"/>
          </baseAddresses>
        </host>
        <!-- This endpoint is exposed at the base address provided by the host: http://localhost:8080/WCFService/dataservice.svc  -->
        <endpoint address="" binding="wsHttpBinding" contract="myService.CService.ICDataService"/>
        <!-- the mex endpoint is exposed at http://localhost/servicemodelsamples/service.svc/mex 
           To expose the IMetadataExchange contract, you 
           must enable the serviceMetadata behavior as demonstrated below -->
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>

    <!--For debugging purposes set the includeExceptionDetailInFaults attribute to true-->
    <behaviors>
      <serviceBehaviors>
        <behavior name="ClickDataServiceBehavior">
          <!-- The serviceMetadata behavior publishes metadata through 
             the IMetadataExchange contract. When this behavior is 
             present, you can expose this contract through an endpoint 
             as shown above. Setting httpGetEnabled to true publishes 
             the service's WSDL at the <baseaddress>?wsdl
             eg. http://localhost/servicemodelsamples/service.svc?wsdl -->
          <serviceMetadata httpGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="False"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>

  </system.serviceModel>

<startup><supportedRuntime version="v2.0.50727"/></startup></configuration>


After coding the above build and deployed the .exe as service using InstallUtil tool present in vs2010.



i want to know how to call services method from browser.
AnswerRe: WCF Service Pin
Wes Aday8-Feb-12 3:05
professionalWes Aday8-Feb-12 3:05 
Questionweb mobile application Pin
tek 20097-Feb-12 22:45
tek 20097-Feb-12 22:45 
AnswerRe: web mobile application Pin
David Mujica8-Feb-12 3:33
David Mujica8-Feb-12 3:33 
GeneralRe: web mobile application Pin
tek 20098-Feb-12 7:30
tek 20098-Feb-12 7:30 
GeneralRe: web mobile application Pin
Bernhard Hiller8-Feb-12 20:42
Bernhard Hiller8-Feb-12 20:42 
GeneralRe: web mobile application Pin
tek 20099-Feb-12 0:26
tek 20099-Feb-12 0:26 
QuestionjQuery Autocomplete Failed Pin
awedaonline7-Feb-12 20:20
awedaonline7-Feb-12 20:20 
GeneralRe: jQuery Autocomplete Failed Pin
Bryian Tan8-Feb-12 6:21
professionalBryian Tan8-Feb-12 6:21 
GeneralRe: jQuery Autocomplete Failed Pin
awedaonline8-Feb-12 22:02
awedaonline8-Feb-12 22:02 
AnswerRe: jQuery Autocomplete Failed Pin
jkirkerx8-Feb-12 12:49
professionaljkirkerx8-Feb-12 12:49 
GeneralRe: jQuery Autocomplete Failed Pin
awedaonline8-Feb-12 22:03
awedaonline8-Feb-12 22:03 
GeneralRe: jQuery Autocomplete Failed Pin
jkirkerx9-Feb-12 7:00
professionaljkirkerx9-Feb-12 7:00 
QuestionModalPopup JScript runtime error on properties Drag="true" Pin
Dharmendra-KumarBLR7-Feb-12 0:08
Dharmendra-KumarBLR7-Feb-12 0:08 
AnswerRe: ModalPopup JScript runtime error on properties Drag="true" Pin
Ali Al Omairi(Abu AlHassan)7-Feb-12 21:55
professionalAli Al Omairi(Abu AlHassan)7-Feb-12 21:55 
Questionexpress checkout keep loading didn't return to merchant Pin
awakepoh6-Feb-12 21:20
awakepoh6-Feb-12 21:20 
AnswerRe: express checkout keep loading didn't return to merchant Pin
jkirkerx8-Feb-12 12:54
professionaljkirkerx8-Feb-12 12:54 
GeneralRe: express checkout keep loading didn't return to merchant Pin
awakepoh8-Feb-12 22:46
awakepoh8-Feb-12 22:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.