Set the endpoint url from code in silverlight

31 views
Skip to first unread message

Dave

unread,
Feb 18, 2011, 8:30:00 AM2/18/11
to agatha
does someone has an example how i set the endpoint url in code. I
don't want to use the config file because it's diffuclt with
deployment and the silverlight applications comes with a
webapplication so when i know the url of the silverlight i also know
the url to the webservice.

in wcf i had this: new ServiceClient("configname",
"mineEndpointUrl")';

Davy Brion

unread,
Feb 18, 2011, 8:40:03 AM2/18/11
to agath...@googlegroups.com
you can inherit from Agatha.Common.WCF.AsyncRequestProcessorProxy and do something like this:

    public class MyRequestProcessorProxy : AsyncRequestProcessorProxy
    {
        public MyRequestProcessorProxy ()
            : base("serviceName", GetServiceAddress())
        {
        }

        private static string GetServiceAddress()
        {
            // get the URL from wherever you want
        }
    }

then in your clientconfiguration, pass in the type of MyRequestProcessorProxy to the RequestProcessorImplementation property and you should be good to go

Walter Poch

unread,
Feb 18, 2011, 8:40:54 AM2/18/11
to agatha-rrsl
Hi Dave, I'm using this code in order to configure the proper URL on SL, so I don't have to change it between environments.

            var servicePath = Current.Host.Source.Scheme
                    + "://" + Current.Host.Source.Host
                    + ":" + Current.Host.Source.Port + CAPTURA_FIRMA_SERVICE_PATH; //Constant to my .svc
                    
             if (servicePath.StartsWith("file")) return new CapturaFirmaServiceClient();
             return new CapturaFirmaServiceClient("CustomBinding_CapturaFirmaService", servicePath);

Regards,


2011/2/18 Dave <dave....@xs4all.nl>



--
Saludos,

Walter G. Poch
Sr. .Net Developer
--------------------------------------------
Cell: +54 (9 341) 3353273
walte...@gmail.com

Dave

unread,
Feb 18, 2011, 9:02:27 AM2/18/11
to agatha
tnx. already found this post but it wasn't completed so it really
helped me

On 18 feb, 14:40, Walter Poch <walter.p...@gmail.com> wrote:
> Hi Dave, I'm using this code in order to configure the proper URL on SL, so
> I don't have to change it between environments.
>
>             var servicePath = Current.Host.Source.Scheme
>                     + "://" + Current.Host.Source.Host
>                     + ":" + Current.Host.Source.Port +
> CAPTURA_FIRMA_SERVICE_PATH; //Constant to my .svc
>
>              if (servicePath.StartsWith("file")) return new
> CapturaFirmaServiceClient();
>              return new
> CapturaFirmaServiceClient("CustomBinding_CapturaFirmaService", servicePath);
>
> Regards,
>
> 2011/2/18 Dave <dave.sm...@xs4all.nl>
>
> > does someone has an example how i set the endpoint url in code. I
> > don't want to use the config file because it's diffuclt with
> > deployment and the silverlight applications comes with a
> > webapplication so when i know the url of the silverlight i also know
> > the url to the webservice.
>
> > in wcf i had this: new ServiceClient("configname",
> > "mineEndpointUrl")';
>
> --
> Saludos,
>
> Walter G. Poch
> Sr. .Net Developer
> --------------------------------------------
> Cell: +54 (9 341) 3353273
> walter.p...@gmail.com
Reply all
Reply to author
Forward
0 new messages