Sayfayı Yazdır | Pencereyi Kapat

SilverLight dan Webservis'e erişim

Nereden Yazdırıldığı: Datakent
Kategori: Diğer bölümler
Forum Adı: C# & ASP.NET
Forum Tanımlaması: C# ve ASP.NET ile ilgili soru / sorun ve paylaşım bölümü
URL: http://forum.datakent.com/forum_posts.asp?TID=2363
Tarih: 10.Haziran.2024 Saat 20:30


Konu: SilverLight dan Webservis'e erişim
Mesajı Yazan: murat turan
Konu: SilverLight dan Webservis'e erişim
Mesaj Tarihi: 29.Nisan.2012 Saat 18:06
SilverLight ve WPF 'den webservis'e erişirken ilk aşamada aşağıdaki hata benzeri hata alabilirsiniz.
 
An error occurred while trying to make a request to URI 'http://192.168.2.2/xFile/WebService.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.
Bu hatanın çözümü:
ISS'in wwwroot  klasörüne aşağıdaki isimlerdeki dosyaları oluşturun. (varsayılan yol: C:\inetpub\wwwroot )
 
1. dosya adı: clientaccesspolicy.xm
 
<?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>
 
2. dosya adı: crossdomain.xml
 
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM " http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd - 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>
 
 
 
akabinde web servis'e erişebilirsiniz.
Erişim örneği:
 
        private void button3_Click(object sender, RoutedEventArgs e)
        {
            ServiceReference1.WebServiceSoapClient xx = new ServiceReference1.WebServiceSoapClient();
            xx.testxCompleted+=new EventHandler<ServiceReference1.testxCompletedEventArgs>(xx_testxCompleted);
            xx.testxAsync(textBox1.Text);
        }
 
        void xx_testxCompleted(object sender, ServiceReference1.testxCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                textBox1.Text = e.Result;
             }
            else
            {
                label1.Content = e.Error.ToString();
            }
        }
 


-------------
http://www.kasatakip.com - Kasa Takip  |  http://www.caritakip.com - Cari Takip  |  http://www.evraktakip.com - Evrak Takip  |  http://www.etasqlmobil.com - ETA SQL Mobil



Sayfayı Yazdır | Pencereyi Kapat