This is a migrated thread and some comments may be shown as answers.

Set service-bindings programmatically

6 Answers 170 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Rudolf Bösch
Top achievements
Rank 1
Rudolf Bösch asked on 25 Oct 2011, 08:47 AM
Hi all

I'm looking for a way to set the bindings for the reporting-service (in a Silverlight application) on the fly rather than declaring them in the web.config. The reason is that I use these reports on http and https sites depending on the client.

I did that before with WCF services, but I can't figure out where to instantiate the bindings for the reporting-service ...

6 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 25 Oct 2011, 08:50 AM
Hi Rudolf Bösch,

Check the following help article for more information on your inquiry: Using Custom Bindings.

Best wishes,
Steve
the Telerik team

Q2’11 SP1 of Telerik Reporting is available for download (see what's new). Get it today.

0
Rudolf Bösch
Top achievements
Rank 1
answered on 25 Oct 2011, 01:07 PM
Hello Steve

Thak you for the answer.
 
This seems to work basically, however I'm confused since it seems to need an entry in the web.config anyways - it leads in a "not found" error (and these are not catchable inside the reports) if there's no entry in the config.

It looks to me as if the report-component is initialized with the settings from the config file and then replaced with the binding from the piece of code - this does not make sense, or am I completely wrong?
0
Rudolf Bösch
Top achievements
Rank 1
answered on 27 Oct 2011, 08:57 AM
Hello Steve

If I understand that right, there's no solution to really create the bindings on the fly.
Without an entry in the Web.Config, the report crashes - this is no solution for my problem.

Is there a further change to expect in the future?
0
Steve
Telerik team
answered on 28 Oct 2011, 02:43 PM
Hi Rudolf Bösch,

Thank you for the additional information, it seems we have misunderstood your initial inquiry.
Generally whenever you need https support, the solution is to configure the corresponding bindings of the service to use Transport security mode, see Enable SSL for Telerik Reporting WCF service help article for more info. You should configure the site as well and this way when you access the report viewer from https page, it would use the SSL enabled service. You can see this approach in action in our online demos which have SSL enabled for the reporting service.
Anyway according to your last posts, you talk about the configuration file in the web application hosting the Silverlight project (web.config). As you probably know this file resides on the server and not on the Silverlight client. It is the Reporting Service that acts as a communication interface between the client programs and the report server. The metadata that is placed in the .svc file is required when hosting WCF service and contains the name of the service and an optional custom service host factory.
So for what you're trying to accomplish you would have to create ServiceHostFactory and use that optional factory attribute to specify your custom service host factory implementation. For more information refer to:
As you see these are requirements for any WCF service and not something specific to our Telerik Reporting WCF Service.

Best wishes,
Steve
the Telerik team

Q2’11 SP1 of Telerik Reporting is available for download (see what's new). Get it today.

0
Rudolf Bösch
Top achievements
Rank 1
answered on 02 Nov 2011, 03:33 PM
Thanks Steve
these are nice samples and documentations - but let us go back to my problem will you?

Since I encounter that issue already before RIA-Services where released I already had to find some solutions to it back in WCF Services time... I digged one out to demonstrate (on a standard servcie, nothing to do with telerik) how I did inorder to call an given service called WebService1 :

namespace TestSilverLight.ChildWindows<br>
{<br>
    public partial class UiChangePassword : ChildWindow<br>
    {<br>
          // ... tons of code<br>
              WebService1Client proxy = ServiceBinding.GetWebService1Client(); // this won't work with reports<br>
              proxy.GetAskTelerikQuery("howto?")...<br>
          // ...tons of more code<br>
    }<br>
}<br>
<br>
namespace TestSilverLight.Utility<br>
{<br>
    public class ServiceBinding<br>
    {<br>
        #region ServiceClient Generator<br>
        public static WebService1Client GetWebService1Client()<br>
        {<br>
            // let's generate a Binding<br>
            BasicHttpBinding binding = GetBasicBinding();<br>
            // Create the bound service<br>
            return new WebPKSWebService1Client(binding, new EndpointAddress(<br>
                new Uri(Application.Current.Host.Source, "../WebServices/WebService1.svc"))); // ugly but works like a charm<br>
        }        <br>
        #endregion<br>
<br>
        #region Binding Generator<br>
        private static BasicHttpBinding GetBasicBinding()<br>
        {<br>
            // Generate binding either using a HTTP or a HTPPS-Protocol<br>
            BasicHttpBinding binding =<br>
                new BasicHttpBinding(Application.Current.Host.Source.Scheme.Equals("https",<br>
                    StringComparison.InvariantCultureIgnoreCase)<br>
                ? BasicHttpSecurityMode.Transport<br>
                : BasicHttpSecurityMode.None);<br>
            int tOut = ((App)Application.Current).QueryTimeout;<br>
            // Set Buffer-Size<br>
            binding.MaxReceivedMessageSize = int.MaxValue;<br>
            binding.MaxBufferSize = int.MaxValue;<br>
            binding.CloseTimeout = new TimeSpan(0, tOut, 59);<br>
            binding.OpenTimeout = new TimeSpan(0, tOut, 10);<br>
            binding.ReceiveTimeout = new TimeSpan(0, tOut, 59);<br>
            binding.SendTimeout = new TimeSpan(0, tOut, 59);<br>
<br>
            return binding;<br>
        }<br>
        #endregion<br>
    }<br>
}
0
Steve
Telerik team
answered on 07 Nov 2011, 03:06 PM
Hi Rudolf,

The provided code is executed on the Silverlight client and we already pointed you to an article that explains how to create custom bindings (Using Custom Bindings) by implementing IReportServiceClientFactory. The approach to avoid the usage of svc file is described in our last post.
The entries in the application configuration file are required in all cases, in order to host the WCF service:
With all that covered, we're not sure what is the problem you experience so we can advise you accordingly.

Regards,
Steve
the Telerik team

Q2’11 SP1 of Telerik Reporting is available for download (see what's new). Get it today.

Tags
General Discussions
Asked by
Rudolf Bösch
Top achievements
Rank 1
Answers by
Steve
Telerik team
Rudolf Bösch
Top achievements
Rank 1
Share this question
or