Click here to Skip to main content
15,890,185 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi everyone i have problem in web service with Silverlight,
i created web service with hello world and added this reference to my Silverlight apps in vs 2010 and write this code.
C#
private void button1_Click(object sender, RoutedEventArgs e)
       {
           //ServiceReference1.WebService1SoapClient s = new WebService1SoapClient();

           //s.HelloWorldAsync();
           //s.HelloWorldCompleted +=new EventHandler<helloworldcompletedeventargs>(s_HelloWorldCompleted);

           WebService1SoapClient s = new WebService1SoapClient();
         s.HelloWorldCompleted +=new EventHandler<helloworldcompletedeventargs>(s_HelloWorldCompleted);
         s.HelloWorldAsync();


       }
      void s_HelloWorldCompleted(object sender, HelloWorldCompletedEventArgs  e)
       {
           if (e.Error != null)
           {
               textBox1 .Text =e.error.Message;
           }
           else
           {
               textBox1 .Text = "Number of users: " + e.Result;
           }
       } </helloworldcompletedeventargs></helloworldcompletedeventargs>

and when run i have error

An error occurred while trying to make a request to URI 'http://ws.mywebsite.com/WebService1.asmx'. 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.

thanks for any help
Posted
Updated 1-Oct-11 19:42pm
v3

1 solution

You need to place a client access policy in the root directory.
See this[^].

If you want to read more about it - see Network Security Access Restrictions in Silverlight[^].
 
Share this answer
 
Comments
Mostafa Elsadany 1-Oct-11 23:27pm    
crossdomain.xml
where i can find this or where i will add
in my silverlight apps

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900