none
Cross domain error while accessing wcf service

    Question

  • Hi,

    I have a WCF service which is placed on a remote server. The domain of the server is different then the domain of my local system. I have place the clientaccesspolicy.xml and crossdomain.xml files on the root directory of server which hosts the service. when i send a call to the service on server from my silverlight application, i receive following error:-

    An error occurred while trying to make a request to URI 'http://192.168.25.226/AP.FileManager.Service/SPConnector.svc'. 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.

    1. crossdomain.xml and clientaccesspolicy.xml files are placed in the website root directory (in wwwroot) on server.

    2. I am able to access service in browser so the service is working on the server.

    3. i am initializing service in code like

    System.ServiceModel.BasicHttpBinding binding = new System.ServiceModel.BasicHttpBinding();

    SPConnectorClient service = new SPConnectorClient(binding, new System.ServiceModel.EndpointAddress("http://serverIP/AP.FileManager.Service/SPConnector.svc"));

    4. ServiceReferences.ClientConfig 

    <configuration>
        <system.serviceModel>
            <bindings>
                <basicHttpBinding>
                    <binding name="BasicHttpBinding_ISPConnector" maxBufferSize="2147483647"
                        maxReceivedMessageSize="2147483647">
                        <security mode="None" />
                    </binding>
                </basicHttpBinding>
            </bindings>
            <client>
                <endpoint address="http://servername/AP.FileManager.Service/SPConnector.svc"
                    binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISPConnector"
                    contract="Ap.FileManager.Service.ISPConnector" name="BasicHttpBinding_ISPConnector" />
            </client>
        </system.serviceModel>
    </configuration>

     

    5. Clientaccesspolicy.xml and crossdomain.xml

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

    crossdomain

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

    Please identify if anything wrong in the policy files or clientconfig file. any idea about any missing thing. Please reply ASAP.

    Thanks in advance.

    Farhan

     

    Friday, September 03, 2010 8:24 AM