Silverlight application cannot access WCF services on other machines

I have a silverlight application that works fine and can access WCF services that are hosted in the Silverlight application itself. The port used is 1794.

When I deploy to other servers (dev or test or staging), the application cannot access WCF services.

This snippet from my ServiceReference.ClientConfig looks like

<endpoint address="http://localhost:1794/MyWebService.svc"
                binding="customBinding" bindingConfiguration="CustomBinding_MyWebService"
                contract="ConfigMgmtServiceReference.MyWebService"
                name="CustomBinding_MyWebService" />

My root folder also contains the clientaccesspolicy.xml file.

How can I overcome this problem?

+2
source share
1 answer

, localhost:1794 - silverlight , localhost .

, , . : - ( ) (), silverlight ( ).

    private void initEndpoint(ServiceEndpoint endPoint, string serviceName)
    {
        Uri hostUri = Application.Current.Host.Source;
        string wcfBaseUri = string.Format("{0}://{1}:{2}/WebServices/", hostUri.Scheme, hostUri.Host, hostUri.Port);

        endPoint.Address = new EndpointAddress(new Uri(wcfBaseUri + serviceName));
    }

/WebServices , - -. :

        LoggingServiceClient loggingService = new LoggingServiceClient();
        initEndpoint(loggingService.Endpoint, "LoggingService.svc");

, , , . , , -, , silverlight- > webservice .

+1

Source: https://habr.com/ru/post/1746996/


All Articles