locked
Cross-domain WS calls - I tried everything RRS feed

  • Question

  • Please help, I am really desperate. For the last week I tried everything to get my cross-domain web service calls to work. I've read everything I could find about the problem, but still without a success.

     

    My scenario:

    I have Cache web services on a server. They are to be called thru HTTPS with WS-Security ("TransportWithMessageCredential" binding option). These are already developed and tested with other (.NET windows forms) application. Please note that using "Transport" binding option always ends up with the same error.

    I developer SilverLight 3 application to communicate with these services.

     

    Please note, that I:

    1. Have created both clientaccesspolicy.xml and crossdomain.xml files and placed them to the root of the server.
    2. Am testing my SilverLight application from ASP.NET web application (http://localhost:xxxx/...).
    3. Have tried changing collection type from ObservableCollection to List in service reference settings.
    4. Tried sniffing with Web Development Helper - both clientaccesspolicy.xml and crossdomain.xml are correctly returned from server (SilverLight does not request crossdomain.xml in case clientaccesspolicy.xml is in place). No further request to server is made after requesting these files.

     

    My ServiceReferences.ClientConfig file:

    <configuration>
        <system.serviceModel>
            <bindings>
                <basicHttpBinding>
                    <binding name="WSE4NPSoap" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
                        <security mode="TransportWithMessageCredential" />
                    </binding>
                </basicHttpBinding>
            </bindings>
            <client>
                <endpoint address="https://e4vyv.DOMAIN.sk/csp/e4np/E4NP.WS.WSE4NP.cls"
                    binding="basicHttpBinding" bindingConfiguration="WSE4NPSoap"
                    contract="Server.WSE4NPSoap" name="WSE4NPSoap" />
            </client>
        </system.serviceModel>
    </configuration>

     

    My clientaccesspolicy.xml file:

    <?xml version="1.0" encoding="utf-8"?>
    <access-policy>
        <cross-domain-access>
            <policy>
                <allow-from http-request-headers="SOAPAction">
                    <domain uri="*"/>
                </allow-from>
                <grant-to>
                    <resource path="/" include-subpaths="true"/>
                </grant-to>
            </policy>
        </cross-domain-access>
    </access-policy>

     

    My crossdomain.xml file:

    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
    <cross-domain-policy>
        <allow-access-from domain="*" />
        <allow-http-request-headers-from domain="*" headers="SOAPAction" />
    </cross-domain-policy>

     

    My code calling web service method:

    ChannelFactory<WSE4NPSoap> channelFactory = new ChannelFactory<WSE4NPSoap>("*");
    channelFactory.Credentials.UserName.UserName = "USERNAME";
    channelFactory.Credentials.UserName.Password = "PASSWORD";
    WSE4NPSoap ws = channelFactory.CreateChannel();
    GetPlayListRequestBody requestBody = new GetPlayListRequestBody(this.settings.PlayerId, null);
    GetPlayListRequest request = new GetPlayListRequest(requestBody);
    IAsyncResult asyncResult = ws.BeginGetPlayList(request, null, null);
    GetPlayListResponse response = ws.EndGetPlayList(asyncResult);

     

    At runtime I get this error:

    CommunicationException:
    An error occurred while trying to make a request to URI 'https://e4vyv.DOMAIN.sk/csp/e4np/E4NP.WS.WSE4NP.cls'. This could be due to attempting to access a service in a cross-domain way without a proper cross-domain policy in place, or a policy that is unsuitable for SOAP services. You may need to contact the owner of the service to publish a cross-domain policy file and to ensure it allows SOAP-related HTTP headers to be sent. This error may also be caused by using internal types in the web service proxy without using the InternalsVisibleToAttribute attribute. Please see the inner exception for more details.

     

    Thank you very much for any help.

    Thursday, September 24, 2009 4:21 AM

Answers

  • Am testing my SilverLight application from ASP.NET web application (http://localhost:xxxx/...).

    There is a cross-schema issue here, HTTP-hosted silverlight cannot access any resource hosted in HTTPS. Please check this article

    http://msdn.microsoft.com/en-us/library/cc645032(VS.95).aspx

    You need host your silverlight in https as well.

    Thanks,

    Monday, September 28, 2009 4:07 AM

All replies