none
cross domain error

    Question

  • I am getting cross domain error as follows

    An error occurred while trying to make a request to URI 'https://anuph-01.no.org.software-innovation.com/WcfService1/LoginService.svc/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.

    WCF Service code: 

    Cross access policy:

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

    Cross domain policy:

    <?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="*"/>    <allow-http-request-headers-from domain="*" headers="SOAPAction" /></cross-domain-policy>

    Client:

     

    publicpartialclassMainPage : UserControl     {         public MainPage()         {             InitializeComponent();             this.Loaded += newRoutedEventHandler((o, e) =>             {                 ServiceReference1.LoginServiceClient proxy = new ServiceReference1.LoginServiceClient();                 proxy.ClientCredentials.UserName.UserName = "anuphosur";                 proxy.ClientCredentials.UserName.Password = "AnUpHoSuR24#";                 proxy.ForgetPasswordCompleted += newEventHandler<ServiceReference1.ForgetPasswordCompletedEventArgs>((o1, e1) =>                 {                     string a = e1.Result;                     string b = a;                 });                 proxy.ForgetPasswordAsync("anuphosur""R15");                              });                     }     }

    Can anyone help me on this??

         

    Tuesday, November 20, 2012 11:16 AM

Answers

  • Does your client trust your WCF servers SSL certificate? If you used a self signed certificate you probably won't be able to connect.
    Thursday, November 22, 2012 8:44 PM
  • Hi Anup,

    The resolution depends on your environment to a certain degree. If you are working in a test environment you probably don't need to purchase a certificate from a certification authority. For our test environment we set up a Windows Certificate Authority or CA (you can add the CA role to a Windows Server from the add roles area) and connected it to the domain so that it could issue certificates. As long as your client machine and server are on the same domain the clients will trust certificates issued by your CA. Once we had the CA set up and connected to the domain we requested a new certificate from IIS to sign the WCF services. After that the clients started trusting it and the connections worked.

    If you are going to have external clients connect who aren't part of your domain structure you will likely have to purchase a certificate from a certification authority.

    You may have done this already, but I would suggest that you try enabling HTTP on your WCF service and try connecting over that first just to ensure that it isn't something else that is causing the problems.

    Friday, November 23, 2012 1:30 PM

All replies

  • Hi, have you read below article?

    http://msdn.microsoft.com/en-us/library/cc197955(v=vs.95).aspx

    Try to add both clientaccesspolicy.xml and crossdomain.xml file and make sure they have the same value as shown in the article above.

    Best Regards


    Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework

    Wednesday, November 21, 2012 12:37 PM
  • I'm not sure if this will help but you might want to add Content-Type under the headers like this:

    <allow-http-request-headers-from domain="*" headers="SOAPAction,Content-Type"/>
    Also is your crossdomain.xml file in the root of your WCF service directory?
    Wednesday, November 21, 2012 1:28 PM
  • Hi Anup,

    Use the following clientaccesspolicy.xml file.

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


    Ideally clientaccesspolicy.xml is sufficient. If not you can add the another related file crossdomain.xml

    <?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-http-request-headers-from domain="*" headers="SOAPAction,Content-Type"/>
    </cross-domain-policy>

    Also, Just for understanding -

    Where are you adding these files?

    This should be available in the Root Directory of WCF Service hosting application.

    I suspect you kept these files in the Silverlight Hosting application. Which is wrong. It's the WCF Service who will provide this policy access on any call from the Silverlight application. Also, you can check using Fiddler or Nikil Khotari Web Developer at what URI clientaccesspolicy.xml it's expection.

    If the above solves your problem then mark it as relpy.


    Dhananjay Tech Lead

    Thursday, November 22, 2012 7:43 AM
  • Still the same issue. one more thing is i am using https protocol.
    Thursday, November 22, 2012 12:06 PM
  • Does your client trust your WCF servers SSL certificate? If you used a self signed certificate you probably won't be able to connect.
    Thursday, November 22, 2012 8:44 PM
  • yes i am using self signed certificate. what need to be done in order to resolve that error.
    • Edited by Anup Hosur Friday, November 23, 2012 6:04 AM
    Friday, November 23, 2012 6:03 AM
  • Hi Anup,

    The resolution depends on your environment to a certain degree. If you are working in a test environment you probably don't need to purchase a certificate from a certification authority. For our test environment we set up a Windows Certificate Authority or CA (you can add the CA role to a Windows Server from the add roles area) and connected it to the domain so that it could issue certificates. As long as your client machine and server are on the same domain the clients will trust certificates issued by your CA. Once we had the CA set up and connected to the domain we requested a new certificate from IIS to sign the WCF services. After that the clients started trusting it and the connections worked.

    If you are going to have external clients connect who aren't part of your domain structure you will likely have to purchase a certificate from a certification authority.

    You may have done this already, but I would suggest that you try enabling HTTP on your WCF service and try connecting over that first just to ensure that it isn't something else that is causing the problems.

    Friday, November 23, 2012 1:30 PM