SOAP etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
SOAP etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

21 Haziran 2016 Salı

Simple Object Access protocol (SOAP) XML Anatomisi

Giriş
Service Oriented Architecture (SOA) 3 tane temel standarttan oluşur. Bunlar şöyle
- SOAP
- WSDL
- UDDI
SOAP Nedir
Açıklaması şöyle. Temel olarak bir protokoldür. Bu protokoldaki format XML'dir ve gönderilen alınan SOAP mesajları vardır.
SOAP is a protocol that defines how two applications will communicate with each other. Two applications when talking to each other have to follow a common format and that common format has to be based using the XML language.

The XML in SOAP APIs have to follow a SOAP Message standard that consists of an Envelop, Header and Body.
SOAP Mesajları
Açıklaması şöyle. Her mesaj belli bir yapıdadır. 3 kısımdan oluşur
The XML in SOAP APIs have to follow a SOAP Message standard that consists of an Envelop, Header and Body.
1. SOAP Envelope
SOAP mesajı bir envelop içindedir. Zarfı anlatan bir yazı burada. Zarfın içeriği http://schemas.xmlsoap.org/envelope adresinden görülebilir. Zarf kısaca aşağıdaki gibidir.
<?xml version="1.0"?>
<soap:Envelope
  xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
  soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">

...
</soap:Envelope>
2. SOAP Header
Şöyledir.
<S12:Envelope ...>
  <S12:Header>
  ...
  </S12:Header>
...
</S12:Envelope>
İçinde WS-Security bilgileri bulunur. Şöyledir.
<S12:Envelope ...>
  <S12:Header>
  ...
  <wsse:Security>
    <wsse:UsernameToken>
      <wsse:Username>NNK</wsse:Username>
      <wsse:Password Type="...#PasswordDigest">...</wsse:Password>
      <wsse:Nonce>WScqanjCEAC4mQoBE07sAQ==</wsse:Nonce>
      <wsu:Created>2003-07-16T01:24:32</wsu:Created>
      </wsse:UsernameToken>
    </wsse:Security>
  ...
  </S12:Header>
...
</S12:Envelope>
3. SOAP Body
Soap Body içindeki alanlar metod çağrısına çok benzerler. İçlerinde şöyle metod isimleri bulunur.
addUser
createUser
insertUser
İçinde çağrılacak olan metodun isminin ve parametreleri bulunur. Body kısaca aşağıdaki gibidir.
<?xml version="1.0"?>
<soap:Envelope >
  <soap:Body xmlns:m="...">
    ...
  </soap:Body>
</soap:Envelope>
Örnek
Şöyle bir metodumuz olsun
void XMLData(string xmlString);
Şöyle bir SOAP mesajı üretilir.
<soapenv:Envelope 
  xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
  xmlns:tem="http://mycompany.com.tr/">
  <soapenv:Header/>
  <soapenv:Body>
    <tem:XMLData>
      <tem:xmlString>...</tem:xmlString>
    </tem:XMLData>
  </soapenv:Body>
</soapenv:Envelope>
Örnek
Bir başka örnek şöyle
<soap:Body xmlns:m="http://www.example.org/stock">
  <m:GetStockPrice>
    <m:StockName>IBM</m:StockName>
  </m:GetStockPrice>
</soap:Body>
Tüm XML  şöyle
<?xml version="1.0"?>
<soap:Envelope
  xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
  soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">

  <soap:Body xmlns:m="http://www.example.org/stock">
    <m:GetStockPrice>
      <m:StockName>IBM</m:StockName>
    </m:GetStockPrice>
  </soap:Body>

</soap:Envelope>
Örnek
Şöyle yaparız
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                  xmlns:us="http://www.webservicesoap.org/birthday">
    <soapenv:Header/>
    <soapenv:Body>
        <us:getBirthdayRequest>
            <us:day>9</us:day>
            <us:month>11</us:month>
            <us:year>2001</us:year>
        </us:getBirthdayRequest>
    </soapenv:Body>
</soapenv:Envelope>