locked
Sync Framework N-Tier over WCF - WCF Service wont publish! RRS feed

  • Question

  • Hi there everyone

    I have a VS2008 windows forms application that synchronizes a local sql server CE 3.5 to a SQL Server 2008 R2 Express database via WCF hosted in Visual Studio's WCF Service Host. It all works fine in the debugger.

    I have spent hours trying to publish it on my server via FTP, or even on my local IIS.

    I've tried creating a WCF Service App and publishing it through that -http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/71d2dd47-71ec-4d16-9c2e-2944af87ae91

    I've tried creating a ASP.NET MVC App and using that - http://social.microsoft.com/Forums/en/syncdevdiscussions/thread/3b1f49e9-7999-488d-a58c-417b10fd478a

    I've tried creating a regular Website (as JuneT describes in his answer in the above link)

    Nothing has worked so far. When I type in the address of the service in the browser I get the following error:

    Service 'MyServiceLibrary.Service1' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element.

    I cannot create a service reference to my IIS from the client to synchronize, it returns the same error as above.

    I'm thoroughly confused - please help!


    • Edited by CWinks Friday, August 19, 2011 5:51 AM
    Thursday, August 18, 2011 5:33 PM

Answers

  • After all my research I tried something different, and this time it worked. I don't know why or how, but at this point, it doesn't matter much.

    I right clicked my service library project, selected publish, then the button with the three dots and chose IIS. I created a new virtual path and chose a random temp folder on my machine and gave a name. Clicking on publish and pointing my browser to the virtual path/name-of-file.svc actually produced the correct page for me!

    Now that I had that up and running I was able to create a service reference from my client Sync project.

    • Marked as answer by CWinks Friday, August 19, 2011 12:41 PM
    Friday, August 19, 2011 12:41 PM

All replies

  • when you deployed to IIS, did you make some entries in your web.config for the WCF stuff?
    Friday, August 19, 2011 2:29 AM
  • It depends in which of the above scenarios. Each application had its own web.config that I tried to configure exactly the way the example showed.

    I must have gone wrong somewhere.

    For example the simplest of the examples from above : HERE  where the example shows how to create a simple, default Service application, my web.config looks the following:

     <system.serviceModel>
      <services>
       <service name="WcfServiceWTSApp.Service1" behaviorConfiguration="WcfServiceWTSApp.Service1Behavior">
        <!-- Service Endpoints -->
        <endpoint address="" binding="wsHttpBinding" contract="WcfServiceWTSApp.IService1">
         <!--
           Upon deployment, the following identity element should be removed or replaced to reflect the 
           identity under which the deployed service runs. If removed, WCF will infer an appropriate identity 
           automatically.
         -->
         <identity>
          <dns value="localhost"/>
         </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
       </service>
      </services>
      <behaviors>
       <serviceBehaviors>
        <behavior name="WcfServiceWTSApp.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>
    

    I'd be happy to work with any example or start a brand new one, I just want to finally get this thing going...

    Thank you for your time

     

     

    Friday, August 19, 2011 5:49 AM
  • is this your service name MyServiceLibrary.Service1?

    have you made sure you have the corresponding entry for it in the config? what does your svc file contain?

    if you locate the config file from the sample, you should find a sample of the config there.

    Friday, August 19, 2011 6:08 AM
  • Here is what I've got (the above web.config was from another example I tried, it isn't the literal copy of the example provided by Michael in the above link. Sorry)

    This is the contents of web.config

     

    	<system.serviceModel>
    		<services>
    			<service name="MyService.Service1" behaviorConfiguration="MyService.Service1Behavior">
    				<!-- Service Endpoints -->
    				<endpoint address="" binding="wsHttpBinding" contract="MyService.IService1">
    					<!--
        Upon deployment, the following identity element should be removed or replaced to reflect the 
        identity under which the deployed service runs. If removed, WCF will infer an appropriate identity 
        automatically.
       -->
    					<identity>
    						<dns value="localhost"/>
    					</identity>
    				</endpoint>
    				<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
    			</service>
    		</services>
    		<behaviors>
    			<serviceBehaviors>
    				<behavior name="MyService.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>
    

     


    This is the contents of app.config

     

     <system.serviceModel>
     <services>
      <service name="MyServiceLibrary.Service1" behaviorConfiguration="MyServiceLibrary.Service1Behavior">
      <host>
       <baseAddresses>
       <add baseAddress = "http://localhost:8731/Design_Time_Addresses/MyServiceLibrary/Service1/" />
       </baseAddresses>
      </host>
      <!-- Service Endpoints -->
      <!-- Unless fully qualified, address is relative to base address supplied above -->
      <endpoint address ="" binding="wsHttpBinding" contract="MyServiceLibrary.IService1">
       <!-- 
        Upon deployment, the following identity element should be removed or replaced to reflect the 
        identity under which the deployed service runs. If removed, WCF will infer an appropriate identity 
        automatically.
       -->
       <identity>
       <dns value="localhost"/>
       </identity>
      </endpoint>
      <!-- Metadata Endpoints -->
      <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. --> 
      <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
     </services>
     <behaviors>
      <serviceBehaviors>
      <behavior name="MyServiceLibrary.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>
    
    

     

    And finally this is the contents of the svc

     

    <%@ ServiceHost Language="VB" Debug="true" Service="MyServiceLibrary.Service1" CodeBehind="Service1.vb" %>
    

     

    I tried to follow the instructions exactly. But since this is my first WCF project, I don't know exactly what I'm looking for, so I don't know where I'm looking for a "corresponding entry". I've spent a lot of time reading up about WCF and trying to create simple WCF sample projects, with no success yet.

     


    EDIT: I downloaded the sample project from the above link and I'm going to compare the above files in the two project to see if there are any discrepancies.
    Friday, August 19, 2011 6:26 AM
  • Indeed, I did find differences between the sample project I downloaded and my code.

    Firstly I was not able to open the solution because of version difference. I currently run VS2008 and I'm assuming the project was created in VS2010, VS just told me it was created with a newer version of VS.

    When I opened the files and compared them to my own, my auto-generated web.config and app.config files look different.

    Here are the differences I found:

    - The examples web.config is very small, it only contains <System.web>, <system.serviceModel> and <system.webserver> config sections, while mine was very long, had many other sections (like sectionGroups, namespaces, httphandlers etc.), and looked similar to any other automated web.config file I've seen with a regular web app or website. I removed the sections and will try publishing it again.

    - Another difference in both app.config and web.config (which I wasn't able to resolve) was that in my web.configs it specified the behavior configuration and name

    <service name="MyService.Service1" behaviorConfiguration="MyService.Service1Behavior"> 

    and

    <serviceBehaviors>
    				<behavior name="MyService.Service1Behavior"> 

    while in the example's config file it did not have a service name tag, nor a behaviorConfiguration attribute, and in the behavior section it was just:

     

    <serviceBehaviors>
      <behavior>
       <!-- 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>
    

     

    I wasn't able to duplicate this because I got the error tooltip "behavior attribute name was missing"

    Edit: I rebuilding the project with the differences I was able to change in my web.config but nothing changed, I still get the same error as above.

    What am I doing wrong? Can someone help me out??

     


    Friday, August 19, 2011 7:01 AM
  • After all my research I tried something different, and this time it worked. I don't know why or how, but at this point, it doesn't matter much.

    I right clicked my service library project, selected publish, then the button with the three dots and chose IIS. I created a new virtual path and chose a random temp folder on my machine and gave a name. Clicking on publish and pointing my browser to the virtual path/name-of-file.svc actually produced the correct page for me!

    Now that I had that up and running I was able to create a service reference from my client Sync project.

    • Marked as answer by CWinks Friday, August 19, 2011 12:41 PM
    Friday, August 19, 2011 12:41 PM