none
cusomizing the SQL N Tier Sample [Web App Demo] web service RRS feed

  • Question

  • I finally succeeded customizing this sample

    Web App Demo

    to fit my needs but I have one problem I want to upload the SqlWebSyncService to the host I don't know how to call it because in the sample there is no svc file for this web service and I don't have experience in WCF ?

    any suggestions ,

    Thursday, December 16, 2010 10:43 AM

Answers

  • If the server can communcate with the http request/response from/to the client, you can use either self host or IIS host with wsHttpBinding.

    However, for the security authentication, you probably want to use user name / password authentication because client and server are not in the same domain. if you are hosting on IIS, you could use a Asp.net SqlMembershipProvider, if you use self host, you could use customer username/password validator. But to start with you can actually disable security for wsHttpBinding(which means no security at all), then make it work and later add the authentication part. Most of topics above are not directly related to Sync, a WCF forum is better suited for those discussions.

     

    Wednesday, December 22, 2010 5:59 PM
    Answerer

All replies

  • I created a service project in vs and hosted the syncservice in that ... 

     

     

    ServiceHost sqlHost;
    
      public SyncService()
      {
       InitializeComponent();
      }
    
      protected override void OnStart(string[] args)
      {
       try
       {
        sqlHost = new ServiceHost(typeof(SqlWebSyncService));
        sqlHost.Open();
       }
       catch (Exception e)
       {
        throw;
       }
      }
    
      protected override void OnStop()
      {
       if (sqlHost != null)
        sqlHost.Close();
      }
    

     

     

     

    Thursday, December 16, 2010 1:41 PM
  • I'm sorry I didn't get the idea any thanks ,

    I would like to inform you that I don't have access to iis . I just wanna host the web service in my shared host so only I can make virtual directory from control panel and upload the web service files .

     


    Thursday, December 16, 2010 2:20 PM
  • Hi I tried To put the wcf web service in the host and I got this error .

     

    This collection already contains an address with scheme http.  There can be at most one address per scheme in this collection.

     

    any ideas please

    Sunday, December 19, 2010 11:11 AM
  • I solved it by putting this in the web.config for wcf service

    <serviceHostingEnvironment>
          <baseAddressPrefixFilters>
            <add prefix="http://assiakids.com" />
          </baseAddressPrefixFilters>
        </serviceHostingEnvironment>

     

    but I'm facing another problem which is : The Caller was authenticated by the service .

     

    any idea please

    Sunday, December 19, 2010 12:03 PM
  • I finally found the solution for this and It was so easy but

     

    now I'm getting this exception  :

    The open operation did not complete within the allotted timeout of 00:01:00. The time allotted to this operation may have been a portion of a longer timeout.

     

    I increased all time out properties but it is still :

     WSHttpBinding binding = new WSHttpBinding();
                binding.ReaderQuotas.MaxArrayLength = 10485760;
                binding.MaxReceivedMessageSize = 10485760;
                binding.Security.Mode = SecurityMode.None;
                binding.OpenTimeout = binding.CloseTimeout = binding.SendTimeout = new TimeSpan(0, 0, 60);
                binding.ReceiveTimeout = new TimeSpan(0, 0, 60);
                binding.ReliableSession.Enabled = true;
                binding.TransactionFlow = true;

    Sunday, December 19, 2010 2:44 PM
  • looks like the timeout is set to 60 seconds. that seems to be match the error message. You could try to increase the timeout.

    However, can your proxy talk to the service correctly? have you tried to check the service by try the service url in browser, such as

        http://localhost:8000/RelationalSyncContract/SqlSyncService/  originally set in the demo application. (you may have different hostName and port)

    You could also enable WCF Tracing to see what's going on. http://msdn.microsoft.com/en-us/library/ms733025.aspx when you open the trace files, look for errors which are marked as red color.

     

    Monday, December 20, 2010 6:20 PM
    Answerer
  • well I'm really confused about WCF this is the first time I use it and I'm using sample code but I can't call it

    the current problem is that I wanna use this sample :

    http://code.msdn.microsoft.com/Release/ProjectReleases.aspx?ProjectName=sync&ReleaseId=3423

     

    I customized it very well but I uploaded the web service to the host but I can't call it because of Authentication caller failed or something

     

    here is the Web.Config for The WCF service  :

    <authentication mode="Forms" />

    <system.serviceModel>
        <serviceHostingEnvironment>
          <baseAddressPrefixFilters>
            <add prefix="http://mydomain.com" />
          </baseAddressPrefixFilters>
        </serviceHostingEnvironment>
        <services>
          <service behaviorConfiguration="WebSyncContract.SqlWebSyncServiceBehavior" name="WebSyncContract.SqlWebSyncService">
            <endpoint address="" binding="wsDualHttpBinding" contract="WebSyncContract.ISqlSyncContract" >
              <identity>
                <dns value="localhost" />
              </identity>
            </endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
          
          </service>
        </services>
        <bindings>
          <wsDualHttpBinding>
            <binding name="wsDualHttpBinding" maxReceivedMessageSize="10485760" >
              <readerQuotas maxArrayLength="10485760" />
              <security mode="None" />
            </binding>
          </wsDualHttpBinding>
        </bindings>
        <behaviors>
          <serviceBehaviors>
            <behavior name="WebSyncContract.SqlWebSyncServiceBehavior" >
              <serviceMetadata httpGetEnabled="true"  />
              <serviceDebug includeExceptionDetailInFaults="true"  />
              <serviceThrottling maxConcurrentCalls="100" maxConcurrentInstances="100" maxConcurrentSessions="100" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>

     

     

    and the client side is wpf application that :

    I just use the same code in the sample

     

    is there any problem in wcf web.config and Can I call it from a web application that hosted in IIS locally

     

     

    Tuesday, December 21, 2010 8:55 AM
  • The sample from sync framework uses a self-host which does not use IIS hosting.

    If you want to customize that to use IIS hosting, you will need to change the hosting code a little such as add .svc file to your project to specify the service class. Also, from your web.config, you are using wsDualHttpBinding which is a complex binding option. I would recommend you start with wsHttpBinding which the sample is using. by default wsHttpBinding is using windows authentication. If your client and server are on the same network/domain, you won't see a security related problem. You can try your scenarios with client & server on the same machine, start from simple to make it work.

     

    Tuesday, December 21, 2010 6:27 PM
    Answerer
  • Ok thanks a lot and I will try to use wsHttpBinding instead of wsDualHttpBinding but as you said the sample use self-host which doesn't use IIS

    hosting. My question is Can I use self-host in server side especially that server and client are not in the same domain . I'm using shared host on my domain and I don't have direct access to the iis as you know ?

    If I can use self-host , how ?

    regards ,

    Wednesday, December 22, 2010 7:18 AM
  • If the server can communcate with the http request/response from/to the client, you can use either self host or IIS host with wsHttpBinding.

    However, for the security authentication, you probably want to use user name / password authentication because client and server are not in the same domain. if you are hosting on IIS, you could use a Asp.net SqlMembershipProvider, if you use self host, you could use customer username/password validator. But to start with you can actually disable security for wsHttpBinding(which means no security at all), then make it work and later add the authentication part. Most of topics above are not directly related to Sync, a WCF forum is better suited for those discussions.

     

    Wednesday, December 22, 2010 5:59 PM
    Answerer
  • ok thanks I will try that and tell you
    Thursday, December 23, 2010 6:59 AM