v2.5.2
Giriş yap

JQuery.Ajax ile Soap kullanmak

trsherlock
577 defa görüntülendi

Herkese Merhaba,
Web Servisi kullanmak istiyorum daha önce bu sistemi Php ile araştırmalarım sonucu başarabilmiştim.
Bu sefer Jquery ile denemek istiyorum bu konuda yardımcı olabilir misiniz?

Soap Bağlantısı!

Ayrıca
JquerySoap bağlantısındaki jquery.soap kullanmayı denedim fakat yine de beceremedim.

POST /GIBBilgiServisi/GBS.asmx HTTP/1.1
Host: smmmservis.tnb.org.tr
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://gbs.nps.tnb.org.tr/BaglantiTesti"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <BaglantiTesti xmlns="http://gbs.nps.tnb.org.tr/" />
  </soap:Body>
</soap:Envelope>

Başarılı olursa zaman bilgisini vermesi gerekiyor.

HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <ServisHataHeader xmlns="http://gbs.nps.tnb.org.tr/">
      <ServisHata>
        <Mesaj>string</Mesaj>
        <Kod>string</Kod>
      </ServisHata>
    </ServisHataHeader>
  </soap:Header>
  <soap:Body>
    <BaglantiTestiResponse xmlns="http://gbs.nps.tnb.org.tr/">
      <BaglantiTestiResult>dateTime</BaglantiTestiResult>
    </BaglantiTestiResponse>
  </soap:Body>
</soap:Envelope>

Not: Sorgulama yaparken Access to XMLHttpRequest at 'http://smmmservis.tnb.org.tr/GIBBilgiServisi/GBS.asmx' from origin 'http://localhost' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. hatası alıyorum sebebi bu olabilir mi?

Cevap yaz
Cevaplar (1)
tayfunerbilen
1239 gün önce

CORS hatası karşı taraf çözmediği sürece çözülmez. Yapabileceğin en basit çözüm proxy kullanmak olabilir, örneğin istek attığın url'i şu şekilde değiştirip dene;

https://cors-anywhere.herokuapp.com/https://siteadi.com

https://siteadi.com kısmına istek adresini yaz ve $.soap isteğinde o şekilde istek at geri kalan aynı olacak şekilde.

$.soap({
    url: 'https://cors-anywhere.herokuapp.com/https://siteadi.com',
    data: ...
    ...
})

gibi.