Skip to main content

Microsoft Silverlight

Answered Question error: attempting to access a service in a cross-domain way without a proper cross-domain policy in placeRSS Feed

(0)

hazz
hazz

Member

Member

75 points

259 Posts

error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

An error occurred while trying to make a request to URI 'http://localhost:4846/Service1.svc'. This could be due to 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.

Here is the VS08 Dev Environment giving some context to the location of the code where the exception was thrown;

http://1.bp.blogspot.com/_CQoTPxzuRCQ/SWKWZFKcs7I/AAAAAAAAAWQ/n64NrBV5m8s/s1600-h/attempting+to+access+a+service+in+a+cross-domain+way.jpg

 and the entire error is at the top of my blog under Silverlight DataGrid Theming.  http://greghazzard.blogspot.com/

None of the possible solutions that have worked for others have helped me thus far in solving this cross-domain issue. I am using Visual Studio 2008 Development Server and not IIS,  If for some reason my exercise with getting the new Dec 2008 Silverlighgt DataGrid and recommended workaround to get Silverlight SDK Themes to work with the DataGrid has introduced a 'wrinkle' into the mix, then I will gladly move to IIS if there is reason to. For obvious debugging reasons I hope to remain in VS08.

1. setting the binding to basicHttpBindingin the web.config.

  <client>
   <endpoint address="http://localhost:4846/Service1.svc" binding="basicHttpBinding"
    bindingConfiguration="BasicHttpBinding_Service1" contract="ServiceReference1.Service1"
    name="BasicHttpBinding_Service1" />
  </client>
   <service behaviorConfiguration="XTO_Silverlight_WCF_CurrentSummary.Web.Service1Behavior"
    name="XTO_Silverlight_WCF_CurrentSummary.Web.Service1">
    <endpoint address="" binding="basicHttpBinding" contract="XTO_Silverlight_WCF_CurrentSummary.Web.Service1" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
   </service>
 2.  My app began without either clientaccesspolicy.xml or crossdomain.xml. Do I now require one? Here is a discussion about deleting one of them should I have had that problem. Without either one present, that is clearly not causing my current error exception.         http://silverlight.net/forums/t/61381.aspx

3. selecting a specific port address (3012 in my case) under Web properties in the Project settings.

 ServiceReferences.ClientConfig

<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_Service1" maxBufferSize="2147483647"
                    maxReceivedMessageSize="2147483647">
                    <security mode="None" />
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:4846/Service1.svc" binding="basicHttpBinding"
                bindingConfiguration="BasicHttpBinding_Service1" contract="ServiceReference1.Service1"
                name="BasicHttpBinding_Service1" />
        </client>
    </system.serviceModel>
</configuration>
http://1.bp.blogspot.com/_CQoTPxzuRCQ/SWKfOwIp48I/AAAAAAAAAWY/_5eODhA2lVM/s1600-h/specific+port+used+in+cross+domain+error.jpg
 any other ideas anyone? 

With appreciation,

Greg Hazzard

 

hazz

prujohn
prujohn

Contributor

Contributor

3579 points

704 Posts

Answered Question

Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

Yes an access policy file is required.  Sometimes your project may work without it locally(I'm not sure why), but more often than not it's just better to have it.

hazz
hazz

Member

Member

75 points

259 Posts

Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

crossdomain.xml, where have you been all my life! Thank you for steering me in the right direction John. -hazz

<?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>

hazz

the_muso
the_muso

Member

Member

2 points

1 Posts

Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

 Hey there, I'm having similar problems trying to access a remote web service that I have developed and published, but I already have the client access policy and cross domain xml files in the root directory of the web site.

 Using an HTTP snooper I can see that whichever of the files I try to use (I'm trying both of the domain policy file types supported) they are successfully retrieved (200 Status error, without any corruption of the document) and yet I still get this error thrown by Silverlight (I've replaced the domain & folder):

 An error occurred while trying to make a request to URI 'https://domain/folder/BW_ClientGeneral.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. Please see the inner exception for more details.

  Here is the clientaccesspolicy.xml contents:

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

And the crossdomain.xml :

<?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>

 So it seems from my snooper that silverlight IS RECEIVING the policy files, but is still throwing the security exception.

 I guess I could be assuming that it is the policy, but it seems most likely.  I have tested access to the policies over HTTP & HTTPS and can see no problem, but that is to be expected given silverlight seems to be downloading them.  The webservice has been tested and deployed, but this is my first attempt to utilise it since deployment - could there be something in the web.config of the application serving the service?

Can anyone see anything I am missing that might help?

Vaishali999
Vaishali999

Member

Member

6 points

3 Posts

Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

I have both the files on the right place in my project directory still I am getting the same error as mentioned about screen shot Can anyone please help me out.  

clientaccesspolicy.xml <?xml version="1.0" encoding="utf-8"?><access-policy><cross-domain-access><policy>      <allow-from http-request-headers="*">        <domain uri="http://localhost:1881/Service1.svc"/>      </allow-from>      <grant-to>        <resource path="/" include-subpaths="true"/>      </grant-to>    </policy>  </cross-domain-access></access-policy>crossdomain.xml<?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>  

Error Description :

System.ServiceModel.CommunicationException was unhandled by user code
  Message="An error occurred while trying to make a request to URI 'http://localhost:1881/Service1.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. Please see the inner exception for more

details."
  StackTrace:
       at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
       at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
       at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
       at System.ServiceModel.ClientBase`1.ChannelBase`1.EndInvoke(String methodName, Object[] args, IAsyncResult result)
       at SilverlightApplication1.ServiceReference1.Service1Client.Service1ClientChannel.EndGetCustomersByCity(IAsyncResult result)
       at SilverlightApplication1.ServiceReference1.Service1Client.ServiceReference1_IService1_EndGetCustomersByCity(IAsyncResult result)
       at SilverlightApplication1.ServiceReference1.Service1Client.OnEndGetCustomersByCity(IAsyncResult result)
       at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)
  InnerException: System.Security.SecurityException
       Message=""
       StackTrace:
            at System.Net.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
            at System.Net.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
            at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)
       InnerException: System.Security.SecurityException
            Message="Security error."
            StackTrace:
                 at System.Net.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
                 at System.Net.BrowserHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState)
                 at System.Net.AsyncHelper.<>c__DisplayClass2.<BeginOnUI>b__0(Object sendState)
            InnerException:  

 

Harish.Suhanda@hotmail.com
Harish.S...

Member

Member

5 points

4 Posts

Re: Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

Hi,

Try removing the

<identity>

<dns value="localhost"/>

</identity>

Section from your web.config file.

 

-Harish

Vaishali999
Vaishali999

Member

Member

6 points

3 Posts

Re: Re: Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

I changed the localhost still I am geeting the same error. One more thing I want to let you know all that I am also getting error in service reference of datasourse file for  GenericObjectDataSource tag that is element is not declared.

I am using Linq query (DataClasses1.dbml file) for connecting to database. resultant data I am binding data to datagrid using following code

Private Sub btnQuery_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)

Dim client As New ServiceReference1.Service1Client

AddHandler client.GetCustomersByCityCompleted, AddressOf client_GetCustomersByCityCompleted

client.GetCustomersByCityAsync(textBox.Text)

End Sub

Private Sub client_GetCustomersByCityCompleted( _

ByVal sender As Object, _

ByVal e As ServiceReference1.GetCustomersByCityCompletedEventArgs)

dataGrid.ItemsSource = e.Result

End Sub

While running above code I am getting error in following function on bold line.

Public Function EndGetCustomersByCity(ByVal result As System.IAsyncResult) As System.Collections.ObjectModel.ObservableCollection(Of ServiceReference1.Customer) Implements ServiceReference1.IService1.EndGetCustomersByCity

Dim _args((0) - 1) As Object

Dim _result As System.Collections.ObjectModel.ObservableCollection(Of ServiceReference1.Customer) = CType(MyBase.EndInvoke("GetCustomersByCity", _args, result),System.Collections.ObjectModel.ObservableCollection(Of ServiceReference1.Customer))

Return _result

End Function

 

foxjazzhack
foxjazzhack

Member

Member

14 points

44 Posts

Re: Re: Re: Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

 Have you guys figured out how to fix this yet. I am still stumped.

 I have added clientaccesspolicy.xml files to both my projects (service and client) and have added the crossdomain.xml file to my service.

I am still getting the error on cross domain security error when I try to access the wcf which runs at localhost.

Any ideas?

Regards,

foxJ

hazz
hazz

Member

Member

75 points

259 Posts

Re: Re: Re: Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

I admit I don't have this issue dialed in but a couple of checklist items/thoughts "second set of eyes"

do you have this clientaccesspolicy.xml in the root web directory? 

<?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>

 as for crossdomain.xml as below, it doesn't, for me, seem to used in my current solution/project folder. I'm using the Default Web Server within VS08 at the moment.

<?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>

hazz

mokarom
mokarom

Member

Member

123 points

23 Posts

Re: Re: Re: Re: Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

Try configuring the service reference and change the Collection type from System.Collections.ObjectModel.ObservableCollection to System.Collections.Generic.List

mokarom

"if this post answers your question, please mark it as answer."

mokarom
mokarom

Member

Member

123 points

23 Posts

Re: Re: Re: Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

Hi Vaishalli,

Try configuring the service reference and change the Collection type from System.Collections.ObjectModel.ObservableCollection to System.Collections.Generic.List

 Mokarom

 Please Mark as answer if this answers your query.

mokarom

"if this post answers your question, please mark it as answer."

foxjazzhack
foxjazzhack

Member

Member

14 points

44 Posts

Re: Re: Re: Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

My code dies at:

public System.Collections.ObjectModel.ObservableCollection<string> EndGetList(System.IAsyncResult result) {

object[] _args = new object[0];

System.Collections.ObjectModel.ObservableCollection<string> _result = ((System.Collections.ObjectModel.ObservableCollection<string>)(base.EndInvoke("GetList", _args, result)));return _result;

}

with the error

An error occurred while trying to make a request to URI 'http://localhost:64972/PDSListService/Service.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. Please see the inner exception for more details.

 

and my namespace doesn't use observable in xaml.cs

 

Regards,

foxJ

Vaishali999
Vaishali999

Member

Member

6 points

3 Posts

Re: Re: Re: Re: Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

Thanks so much to all my error get resolved.

Vaishali

dashcream
dashcream

Member

Member

15 points

9 Posts

Re: Re: Re: Re: Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

 

Hi All, I hv tried with all above suggestions

1) Tried applying both policy files.

2) Tried Changing to generic.list

3) Binding to basicHttpBinding

Still getting the same problem, and got pisse dof this same error again and again.

Can any one please tell me the exact solution?

foxjazzhack
foxjazzhack

Member

Member

14 points

44 Posts

Re: Re: Re: Re: Re: Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

If your using WCF, work with it in a single silverlight project.

 

Regards,

foxJ

dcpace
dcpace

Member

Member

6 points

3 Posts

Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

 Ok I think I found what was causing me to have the same problem.  I noticed that the random port VS2008 was using today had changed from what it was last week.  I looked at my service refs and my web.config file and they were all using the old port number in the service definitions.  I deleted the service references and then recreated them and everything started working. - I then checked the web.config and service refs and they now have the new port number.

This would go a long way to explain why a working prototype suddenly stopped working on code that had been well tested. - It also makes sense that the error was about cross domain problems.

 

Strange that VS2008 doesn't catch this and make changes but.....

Anyway, that is where I would look next if you are still having this problem. -  YMMV.  Hope it helps.

dashcream
dashcream

Member

Member

15 points

9 Posts

Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

Thank you all.

I was having the same problem with run time port selection, my port was getting changed.

I made it ti fixed port from the property of the wcf services.

And now its working fine.

Cheers!!

ravikirane
ravikirane

Member

Member

14 points

7 Posts

Re: Re: Re: Re: Re: Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

same problem iam getting but cudn't figured it out y

i hv taken silverlight application 

i am using my webservice located @ client server (say http://192:...) and added thru add service ref

i created a Virtual Directory in IIS

and calling in page.xaml.cs file iam using the code

dpWorkshop.WorkshopSoapClient oClient = new SilverlightApplication2.dpWorkshop.WorkshopSoapClient();oClient.GetWorkshopActivityCompleted += new EventHandler<SilverlightApplication2.dpWorkshopActivity.GetWorkshopActivityCompletedEventArgs>(oClient_GetWorkshopActivityCompleted);

oClient.GetWorkshopActivityAsync(570);

 

some thing like that and when i run it in localhost http://localhost/SilverlightApplication2/SilverlightApplication2TestPage.aspx it is returning ntng

and when i run it in VS2008 envi it is showing the same error

plzz help me in this regard

 

 

 

 

 

 

hector_cervantes2
hector_c...

Member

Member

34 points

20 Posts

Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

Thank you, dcpace!  That was the same problem I was having.  It was in the configuration.svcinfo file not the web.config for me.  I set a specific port number to use in the VS Porject Properties.

KyoX94
KyoX94

Member

Member

8 points

9 Posts

Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

 Hello,

I'm in the same case as Hazz and got the same CommunicationException so i tried everything that i found on this forum and on internet :

-Changing the binding to basicHttpBinding

-Adding clientaccesspolicy.xml and crossdomain.xml to the root of both webservice and client

-Removing <identity><dns value="localhost"/></identity>

-Selecting a specific port

-Changing my ObservableCollectin to a List

 I really need help plz.

 

hector_cervantes2
hector_c...

Member

Member

34 points

20 Posts

Re: Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

Are you getting this error when you are debugging through VS?  If so, check the previous two posts.  You might be using VS virutal IIS and the port number might have changed.  You can use a specified port by going to Project properties, then make sure you update the configuration.svcinfo file because it will have a different port number, thus it thinks it is coming from a different domain.

KyoX94
KyoX94

Member

Member

8 points

9 Posts

Re: Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

Thanks for your fast answer ! 

I'm debugging through VS2008. I'm using the VS Development server on a specific port : 2044 (the same since the beginning) and in my configuration.svcinfo, i checked that the endpoint address was right : http://localhost:8731/Design_Time_Addresses/ProductService/Service1/ and the serializedValue is the same.

hector_cervantes2
hector_c...

Member

Member

34 points

20 Posts

Re: Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

Yeah.  Change the localhost port to 2044 on the service URI in the configuration.svcinfo:

http://localhost:2044/Design_Time_Addresses/ProductService/Service1/

KyoX94
KyoX94

Member

Member

8 points

9 Posts

Re: Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

In fact i can't access to my webservice from another domain like http://localhost:2044/Design_Time_Addresses/ProductService/Service1/. I guess that it's a crossdomain problem and i put a clientaccesspolicy.xml and crossdomain.xml to the root of my webservice project but it doesn't seem to work.

varshavmane
varshavmane

Contributor

Contributor

6739 points

1,583 Posts

Re: Re: Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

hi,

Instead of putting it their just put that in C:\Inetpub\wwwroot folder and check whether http://localhost/crossdomain.xml and http://localhost/clientaccesspolicy.xml runs fine.

Hope this solves your problem.

Please "Mark as Answer" if this post answered your question. :)
Visit my Blog: http://varshavmane.blogspot.com/

hector_cervantes2
hector_c...

Member

Member

34 points

20 Posts

Re: Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

Is the service in the same solution as your silverlight application in visual studio?  Try this: right-click the Service1.svc file in the soltuion explorer in VS and click on Browse.  Whenn the browser comes up, copy the URL and  that URL for the service end point.  The other thing that you can try is to delete the service reference from your silverlight application and re-add it. 

madact
madact

Member

Member

4 points

2 Posts

Re: Re: Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

Hi,
I have a silverlight application which works fine on my local system.But gives me error while hosted in IIS.

I have a Silverlight-Enabled WCF service in "MyProject.Web" project.A service reference in silverlight project is hosting that WCF.
(MyProject.Web and silverlight app are in same solution).Everything works fine on my localsystem.But the application fails in IIS throwing the following exception:
An error occured while trying to make a request to URI 'http://localhost:2727/Service.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 ita llows SOAP-related HTTP headers to be sent.Please see the inner exception for more details.


Can anyone please suggest how to overcome this error.I have added both policy files but I think they are not detected at all.Pls suggest where the files should be added or some other solution.

hector_cervantes2
hector_c...

Member

Member

34 points

20 Posts

Re: Re: Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

If you published it to your local IIS, do you still need the port 2727?  Try removing the port number from the configuration.svcinfo file. 

KyoX94
KyoX94

Member

Member

8 points

9 Posts

Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

Thanks everybody, i solved the problem adding a WCF project to my Silverlight so i haven't any crossdomain issue.

 

Sriram Ramaswami
Sriram R...

Member

Member

11 points

51 Posts

Re: Re: Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

 

varshavmane:

hi,

Instead of putting it their just put that in C:\Inetpub\wwwroot folder and check whether http://localhost/crossdomain.xml and http://localhost/clientaccesspolicy.xml runs fine.

Hope this solves your problem.

 

 Had The Issue. Works When i Put it in InetPub.. Thanks a Lot...

 

Sriram

varshavmane
varshavmane

Contributor

Contributor

6739 points

1,583 Posts

Re: Re: Re: Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

My pleasure Smile

Please "Mark as Answer" if this post answered your question. :)
Visit my Blog: http://varshavmane.blogspot.com/

adamsurg
adamsurg

Member

Member

2 points

1 Posts

Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

Thanks, crossdomain.xml worked for me too, but don't forget to delete clientaccesspolicy.xml or it'll just get ignored.  I'm not really happy with this as a solution, but it's nice to move on and do something else for a bit too.

Changing ObservableCollection to Generic.List seems to be a fairly random suggestion, I can't see how it will make any difference.

sudarajan
sudarajan

Member

Member

5 points

3 Posts

Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

hi , can  u help me if u have the solve problem  what u  have face for cross domain . i tried a lot to fix this problem  i am not able to do this plz help me how to slove this issue

hector_cervantes2
hector_c...

Member

Member

34 points

20 Posts

Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

Hi sudarajan.  Can you explain your situation a little bit more?  What is the problem you are having and what exactly have you tried?  Do you have the client policy file in the www root folder?  Are you getting this error when you debug through Visual Studio? 

ajay01
ajay01

Member

Member

4 points

2 Posts

Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

please make another *.svc file then it will be perfect.never hang out try to do messy things.

ajay01
ajay01

Member

Member

4 points

2 Posts

Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

 

don't worry please remove

<identity>

<dns value="localhost"/>

</identity>

Section from your web.config/app.config file.

 

varshavmane
varshavmane

Contributor

Contributor

6739 points

1,583 Posts

Re: Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

Hi,

If your Project contains .dbml file then please check whether that file has serialization Mode set to Unidirectional.

HTH Smile

Please "Mark as Answer" if this post answered your question. :)
Visit my Blog: http://varshavmane.blogspot.com/

wazzzuup
wazzzuup

Member

Member

2 points

1 Posts

Re: Re: Re: Re: Re: Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

try the following, taht helped me in ServiceReferences.ClientConfig file in SilverLight Application Project change name of endpoint to its IP for example I had: and changed to and it worked for me! I don't know what is the core difference but this is the fact ...

Am I Evil?
Yes I Am!

svsriraj
svsriraj

Member

Member

10 points

12 Posts

Re: Re: Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

 Hi .. I am trying to access a service that i hosted in IIS with SSL in localhost.

I added serviceReference to Silverlight using https and it get added correctly.

But when i try to invoke the service method I get following error

 

"An error occurred while trying to make a request to URI 'https://dhk82bs.bspl.ho/MA_WCF/BudgetService.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."

But there is a crossdomain.xml in  https://dhk82bs.bspl.ho/MA_WCF/ceossdomain.xml and also in https://dhk82bs.bspl.ho/crossdomain.xml

 

Invoking app is using http and not https. Suggest some solution for this problem.. 

 

Thanks in advance

 

varshavmane
varshavmane

Contributor

Contributor

6739 points

1,583 Posts

Re: Re: Re: Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

Hi, Check this: http://chakkaradeep.wordpress.com/2008/05/31/silverlight-and-wcf/ HTH Smile

Please "Mark as Answer" if this post answered your question. :)
Visit my Blog: http://varshavmane.blogspot.com/

svsriraj
svsriraj

Member

Member

10 points

12 Posts

Re: Re: Re: Re: Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

 No that link only explain abt how to use normal WCF bervice in VS server . In that case my app also works fine. But using IIS server problem arises.

varshavmane
varshavmane

Contributor

Contributor

6739 points

1,583 Posts

Re: Re: Re: Re: Re: Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

Hi,

Check this:

http://blogs.msdn.com/carlosfigueira/archive/2008/03/07/enabling-cross-domain-calls-for-silverlight-apps-on-self-hosted-web-services.aspx

http://weblogs.asp.net/tolgakoseoglu/archive/2008/03/18/silverlight-2-0-and-wcf.aspx

http://www.tipsdotnet.com/TechBlog.aspx?PageIndex=0&BLID=11

Finally on Google search:

http://www.google.com/search?hl=en&q=WCF+hosting+on+IIS+%2B+could+be+due+to+attempting+to+access+a+service+in+a+cross-domain+%2B+Silverlight&aq=f&oq=&aqi=

HTH Smile

Please "Mark as Answer" if this post answered your question. :)
Visit my Blog: http://varshavmane.blogspot.com/

akhi4akhil
akhi4akhil

Member

Member

6 points

3 Posts

Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

Copying the crossdomainpolicy.xml into the service folder should fix the issue.

 I Had the same issue and got solves by copying the mentioned file

Regards

Akhil

Mark as answer if helpfull

Regards,
Akhil
Mark as Answer if found helpfull.

mehmet.kaplan
mehmet.k...

Member

Member

4 points

2 Posts

Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

.style1 { color: #FF0000; }

The errorwith inner message at the following form, if occurs after abnormal termination

An error occurred while trying to make a request to URI .............. 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.

then the problem most probably occured because of the fact that the client side is keeping previous port number for the WCF. In order to solve quickly, simply follow the steps as stated belor:

i.  Rename the service at client (silverlight) side.

ii. Re-discover the service.

iii. Add new service and give the previously used name.

iv. Remove the old service.

arnieberg
arnieberg

Member

Member

4 points

2 Posts

Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

 I have not read all the posts in this thread but I had the same symptom, and here is my gem of a solution: 

 I copied the crossdomain.xml and clientaccesspolicy.xml files from the virtual root folder of the service on IIS that I was trying to access through basicHttp binding TO the root of the WEB SITE ITSELF!  My Silverlight app took off.

nitinpa
nitinpa

Member

Member

6 points

3 Posts

Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

I have a test WCF service with only 1 test method. The service exposes basicHttpBinding endpoint and in hosted in IIS 6.0. The service uses integrated windows authentication.

 

I am able to consume the service with a windows client without any issue. With the Silverlight 3 client I am getting the following exception:

 Exception Message------------------------An error occurred while trying to make a request to URI 'http://SERVER:8090/Service.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. Inner Exception --------------------

{System.Security.SecurityException ---> System.Security.SecurityException: Security error.

   at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)

   at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState)

   at System.Net.Browser.AsyncHelper.<>c__DisplayClass2.<BeginOnUI>b__0(Object sendState)

   --- End of inner exception stack trace ---

   at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)

   at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)

   at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)}

 To resolve this I created and placed the ClientAccessPolicy.xml and crossdomain.xml files in the root folder of my WCF service (http://SERVER:8090/clientaccesspolicy.xml). This file is also getting successfully downloaded when the SL client calls the service. Here is the content of ClientAccessPolicy.xml (pretty standard, I am allowing all domains and all headers)<?xml version="1.0" encoding="utf-8" ?><access-policy>  <cross-domain-access>    <allow-from http-request-headers="*">      <domain uri="*" />    </allow-from>    <grant-to>      <resource path="/" include-subpaths="true"/>    </grant-to>  </cross-domain-access>

</access-policy>

 

The web.config of the WCF service looks like this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
    <bindings>
      <basicHttpBinding>
        <binding name="basicHttpBindingConfig">
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Ntlm"/>
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="ServiceBehavior" name="PWRTestService.Service">
        <endpoint address="" binding="basicHttpBinding"
            bindingConfiguration="basicHttpBindingConfig" contract="PWRTestService.IService" />
      </service>
    </services>
    <client>
      <endpoint address="http://SERVER:8090/Service.svc"
          binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService"
          contract="PWRServiceReference.IService" name="BasicHttpBinding_IService" />
    </client>
  </system.serviceModel>
</configuration>
 

The client reference configuration is:

<configuration>
 <system.serviceModel>
  <bindings>
   <basicHttpBinding>
    <binding name="BasicHttpBinding_IService" maxBufferSize="2147483647"
                    maxReceivedMessageSize="2147483647">
     <security mode="TransportCredentialOnly" />
    </binding>
   </basicHttpBinding>
  </bindings>
  <client>
   <endpoint address="http://SERVER:8090/Service.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService"
                contract="PWRServiceReference.IService" name="BasicHttpBinding_IService" />
  </client>
 </system.serviceModel>
</configuration>

I have already tried the following:

1. Copied the clientaccessploicy.xml in c:\inetpub\wwwroot

2. Tried almost all steps given in this and other posts.

But the exception has not been resolved. Any help will be appreciated.

varshavmane
varshavmane

Contributor

Contributor

6739 points

1,583 Posts

Re: Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

Hi,

Try changing the endpoint address of your client config file from server to the server IP and rebuild the solution.

Hope that helps.

Please "Mark as Answer" if this post answered your question. :)
Visit my Blog: http://varshavmane.blogspot.com/

nitinpa
nitinpa

Member

Member

6 points

3 Posts

Re: Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

varshavmane:

Hi,

Try changing the endpoint address of your client config file from server to the server IP and rebuild the solution.

Hope that helps.

Sorry I tried that as well bt it does not work.

varshavmane
varshavmane

Contributor

Contributor

6739 points

1,583 Posts

Re: Re: Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

Did you check with Firewall?

Please "Mark as Answer" if this post answered your question. :)
Visit my Blog: http://varshavmane.blogspot.com/

nitinpa
nitinpa

Member

Member

6 points

3 Posts

Re: Re: Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

varshavmane:

Did you check with Firewall?

There is no issue with firewall. I am able to consume the service fro asp.net hosted alongwith the silverlight application.

Demian_Pace
Demian_Pace

Member

Member

2 points

1 Posts

Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

Nitinpa,

I dont know if either of these suggestions will help but they solved my similar problem sometime ago so I thought I'd share them

Do you have your crossdomain.xml and clientaccesspolicy.xml in the root of the application?

 If not, here is a quick and dirty version of both you can use.

clientaccesspolicy.xml

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

crossdomain.xml

<?xml version="1.0" encoding="utf-8"?>
<cross-domain-policy>
  <allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>

One other problem I had when I first started using silverlight is that visual studio would pick a random port number for testing and when the project was built, it saved that port number in the service reference.  - A week later, visual studio had picked another port but did not update the service references.  -  I have since learned to set all of my projects to a specific port in the project.web properties window before creating my service references. - If you need to change the port number, I have found it is easier to fix the port, then delete and recreate the service reference than to try to chase down everywhere the old port number lives. - You don;t have to delete the service itself, just the reference and recreate. - Finally check your web.config for port number issues.

 

Hope this helps. At the least it is two more things to check off the list as not the problem. - HAHA

tjanczuk
tjanczuk

Member

Member

86 points

17 Posts

Re: error: attempting to access a service in a cross-domain way without a proper cross-domain policy in place

I have created a Visual Studio 10 online item template to facilitate creation of client access policy files for Silverlight applications. You can access this by searching online item templates in the Add | New Item dialog for an existing Visual Studio Project, or by installing the template from here: http://visualstudiogallery.msdn.microsoft.com/en-us/83ad9abd-5212-4f8d-9d4f-4fd4319c5731.

Thanks,
Tomasz Janczuk

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities