none
can't connect to SQL Server 2012 Express database via web service in a windows store app (c#,XAML) RRS feed

  • Question

  • hi everyone,

    i'm developping a windows store app and i'm trying to connect my app to sql server 2012 database trough web service (WCF). but when i run the app, it generates an exception:

    System.ServiceModel.EndpointNotFoundException

    there was no endpoint listening at http://localhost:51233/DataProvider.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.

    does anyone have any idea about it????

    how can i fix it??

    thanks for advance

    Saturday, March 22, 2014 9:24 PM

Answers

  • You application stopped running or isn't listening at port number 51233.  From the error message I cannot determine if the issue is with the application interface to the SQL server or some other type error.  I would built a test application get the interface to the SQL database working before I put it into a service.

    jdweng

    Sunday, March 23, 2014 1:50 AM
  • Use the correct connection statement.  The instance of the SQL Server is found in the login window to the database using SQL Server Management Studio (SSMS).  Use a connection statement like below

    Server=myServerName\myInstanceName;Initial Catalog=myDataBase;Integrated Security=SSPI;

    When you start your computer SQL Server starts a service that is listening using a network connection.


    jdweng

    Sunday, March 23, 2014 12:58 PM
  • Hi,

    From your description, I know that you want to connect to SQL Server 2012 Express database in a windows store app, then please try to refer to download the following code:
    #Download code:Connect Windows 8 Store Application to SQL Server DB using TCP (Windows Service):
    http://code.msdn.microsoft.com/windowsapps/Connect-Windows-8-Store-f9652c36/view/Discussions .

    Also when meeting error, please try to enable the wcf tracing to get more information.

    The following configuration taken from MSDN can be applied to enable tracing on your WCF service.

    <configuration>
      <system.diagnostics>
        <sources>
          <source name="System.ServiceModel"
                  switchValue="Information, ActivityTracing"
                  propagateActivity="true" >
            <listeners>
                 <add name="xml"/>
            </listeners>
          </source>
          <source name="System.ServiceModel.MessageLogging">
            <listeners>
                <add name="xml"/>
            </listeners>
          </source>
          <source name="myUserTraceSource"
                  switchValue="Information, ActivityTracing">
            <listeners>
                <add name="xml"/>
            </listeners>
          </source>
        </sources>
        <sharedListeners>
            <add name="xml"
                 type="System.Diagnostics.XmlWriterTraceListener"
                 initializeData="Error.svclog" />
        </sharedListeners>
      </system.diagnostics>
    </configuration>

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, March 24, 2014 9:06 AM
    Moderator

All replies

  • You application stopped running or isn't listening at port number 51233.  From the error message I cannot determine if the issue is with the application interface to the SQL server or some other type error.  I would built a test application get the interface to the SQL database working before I put it into a service.

    jdweng

    Sunday, March 23, 2014 1:50 AM
  • i created a database an sql server 2012 express then i created the web service the i created the app and i added a the service as a reference then i run it and this error show up i didn't have any idea how to solve it 
    Sunday, March 23, 2014 8:10 AM
  • It is not necessary to create a service to connect to SQL Server since the database is a server.  Creating a service allows you to add your own wrapper around the database to add additional management of the database.

    To debug the service I would first run it inside VS.  You can then have a client connect to the service and determine where the error(s) are occurring.  If you post the inner exception I can give you some clues what is happening.  The inner exception can be found in the exception handler printing the StackTrace property instead of the Message property.


    jdweng

    Sunday, March 23, 2014 12:09 PM
  • how can i connect my app to sql server database without using web service???
    Sunday, March 23, 2014 12:21 PM
  • without using windows azure also
    Sunday, March 23, 2014 12:24 PM
  • Use the correct connection statement.  The instance of the SQL Server is found in the login window to the database using SQL Server Management Studio (SSMS).  Use a connection statement like below

    Server=myServerName\myInstanceName;Initial Catalog=myDataBase;Integrated Security=SSPI;

    When you start your computer SQL Server starts a service that is listening using a network connection.


    jdweng

    Sunday, March 23, 2014 12:58 PM
  • thanks a lot sir can you give me more informations ??
    Sunday, March 23, 2014 1:13 PM
  • What type of info?

    jdweng

    Sunday, March 23, 2014 1:18 PM
  • i'm stuck with the same exception: there was no endpoint 
    Sunday, March 23, 2014 1:41 PM
  • To make a connection you need a service that is listening on the port before that client starts to run.  The term client has two meanings

    1) The socket (which is a TCPClient class) which is required on both the client and server application

    2) The application layer.  Normally you would have a TCPListener at the server end of the connection and the TCPClient at the client end of the connection.

    Note : The client and server can also be Http instead of TCP.


    jdweng

    Sunday, March 23, 2014 1:54 PM
  • i realise that in my web. config file i don't have any endpoint. i guess the problem may came from there?? am i correct???
    Sunday, March 23, 2014 1:59 PM
  • this is my web.config content:

    <?xml version="1.0" encoding="utf-8"?>

    <configuration>
      <configSections>
        <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
      </configSections>
      <appSettings>
        <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
      </appSettings>
      <system.web>
        <compilation debug="true" targetFramework="4.5" />
        <httpRuntime targetFramework="4.5" />
      </system.web>
      <system.serviceModel>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <!-- Pour éviter la divulgation d'informations de métadonnées, définissez les valeurs ci-dessous sur false avant le déploiement -->
              <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
              <!-- Pour recevoir les détails de l'exception dans les erreurs à des fins de débogage, définissez la valeur ci-dessous sur true. Pour éviter la divulgation d'informations d'exception, définissez-la sur false avant le déploiement -->
              <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <protocolMapping>
          <add binding="basicHttpsBinding" scheme="https" />
        </protocolMapping>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
      </system.serviceModel>
      <system.webServer>
        <security>
          <requestFiltering>
            <requestLimits maxAllowedContentLength="204800000" />
            <fileExtensions allowUnlisted="true"></fileExtensions>
          </requestFiltering>
        </security>
        <modules runAllManagedModulesForAllRequests="true" />
        <!--
            Pour parcourir le répertoire racine de l'application Web lors du débogage, définissez la valeur ci-dessous sur true.
            Définissez-la sur false avant le déploiement pour ne pas divulguer d'informations du dossier de l'application Web.
          -->
        <directoryBrowse enabled="true" />
      </system.webServer>
      <connectionStrings><add name="EmpDatabaseEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=SANA\SQLEXPRESS;initial catalog=EmpDatabase;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /><add name="LearnerDBEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=SANA\SQLEXPRESS;initial catalog=LearnerDB;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" /></connectionStrings>
      <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
        <providers>
          <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
        </providers>
      </entityFramework>
    </configuration>

    Sunday, March 23, 2014 2:28 PM
  • I'm not a soap expert.  You need a server with a client class that uses the port number 51233.  Then you need also need a second connection to the SQLExpress database.

    jdweng

    Sunday, March 23, 2014 7:36 PM
  • Hi,

    From your description, I know that you want to connect to SQL Server 2012 Express database in a windows store app, then please try to refer to download the following code:
    #Download code:Connect Windows 8 Store Application to SQL Server DB using TCP (Windows Service):
    http://code.msdn.microsoft.com/windowsapps/Connect-Windows-8-Store-f9652c36/view/Discussions .

    Also when meeting error, please try to enable the wcf tracing to get more information.

    The following configuration taken from MSDN can be applied to enable tracing on your WCF service.

    <configuration>
      <system.diagnostics>
        <sources>
          <source name="System.ServiceModel"
                  switchValue="Information, ActivityTracing"
                  propagateActivity="true" >
            <listeners>
                 <add name="xml"/>
            </listeners>
          </source>
          <source name="System.ServiceModel.MessageLogging">
            <listeners>
                <add name="xml"/>
            </listeners>
          </source>
          <source name="myUserTraceSource"
                  switchValue="Information, ActivityTracing">
            <listeners>
                <add name="xml"/>
            </listeners>
          </source>
        </sources>
        <sharedListeners>
            <add name="xml"
                 type="System.Diagnostics.XmlWriterTraceListener"
                 initializeData="Error.svclog" />
        </sharedListeners>
      </system.diagnostics>
    </configuration>

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, March 24, 2014 9:06 AM
    Moderator