Pemahaman Struktur WSDL Dasar – (Bahasa Deskripsi Layanan Web) Dijelaskan
Diterbitkan: 2020-08-24Anda mungkin telah melihat posting saya sebelumnya tentang panggilan SOAP vs. REST. Sekarang hari perusahaan pindah ke panggilan layanan REST tetapi masih ada sebagian besar perusahaan masih menggunakan SOAP melalui REST. Tutorial ini menjelaskan dasar-dasar WSDL (Web Service Description Language).
Jika Anda memiliki pertanyaan di bawah ini maka Anda berada di tempat yang tepat:
- Apa itu Bahasa Deskripsi Layanan Web (WSDL)?
- Tutorial WSDL
- Dijelaskan Bahasa Deskripsi Layanan Web (WSDL)
- Contoh WSDL – Bahasa Deskripsi Layanan Web
Bahasa Deskripsi Layanan Web (WSDL)
Di Java Web Development World, WSDL adalah format XML untuk menggambarkan layanan jaringan sebagai satu set titik akhir yang beroperasi pada pesan yang berisi informasi berorientasi dokumen atau berorientasi prosedur.
Operasi dan pesan dijelaskan secara abstrak, dan kemudian diikat ke protokol jaringan konkret dan format pesan untuk menentukan titik akhir. Titik akhir konkret terkait digabungkan menjadi titik akhir abstrak (layanan).
WSDL dapat diperluas untuk memungkinkan deskripsi titik akhir dan pesannya terlepas dari format pesan atau protokol jaringan apa yang digunakan untuk berkomunikasi, namun, satu-satunya ikatan yang dijelaskan dalam dokumen ini menjelaskan cara menggunakan WSDL
dalam hubungannya dengan SOAP 1.1, HTTP GET/POST, dan PANTOMIM.

Yang lain harus membaca:
- Buat Contoh WSDL di Eclipse dan Hasilkan Klien
- Cara membangun Layanan RESTful dengan Java menggunakan JAX-RS dan Jersey (Contoh)
Dengan kata lain: Dokumen WSDL mendefinisikan layanan sebagai kumpulan titik akhir jaringan, atau ports
. Di WSDL, definisi abstrak titik akhir dan pesan dipisahkan dari penyebaran jaringan konkret atau pengikatan format data. Hal ini memungkinkan penggunaan kembali definisi abstrak: messages
, yang merupakan deskripsi abstrak dari data yang dipertukarkan, dan tipe port yang merupakan kumpulan operasi abstrak.
Protokol konkret dan spesifikasi format data untuk jenis port tertentu merupakan binding
yang dapat digunakan kembali. Port didefinisikan dengan mengasosiasikan alamat jaringan dengan pengikatan yang dapat digunakan kembali, dan kumpulan port mendefinisikan layanan.
Oleh karena itu, dokumen WSDL menggunakan elemen berikut dalam definisi layanan jaringan:
-
Types
– wadah untuk definisi tipe data menggunakan beberapa sistem tipe (sepertiXSD
). -
Message
– definisi abstrak yang diketik dari data yang dikomunikasikan. -
Operation
– deskripsi abstrak dari tindakan yang didukung oleh layanan. -
Port Type
–set abstrak operasi yang didukung oleh satu atau lebih titik akhir. -
Binding
– protokol konkret dan spesifikasi format data untuk tipe port tertentu. -
Port
– titik akhir tunggal yang didefinisikan sebagai kombinasi dari pengikatan dan alamat jaringan. -
Service
– kumpulan titik akhir terkait.
Elemen | Keterangan |
---|---|
<jenis> | Mendefinisikan tipe data (XML Schema) yang digunakan oleh layanan web |
<pesan> | Mendefinisikan elemen data untuk setiap operasi |
<portType> | Menjelaskan operasi yang dapat dilakukan dan pesan yang terlibat. |
<mengikat> | Mendefinisikan protokol dan format data untuk setiap jenis port |
Contoh: SOAP 1.1 Permintaan/Respon melalui HTTP
Contoh Dokumen XML WSDL.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
<? xml version = "1.0" ?> < definitions name = "StockQuote" targetNamespace = "http://example.com/stockquote.wsdl" xmlns : tns = "http://example.com/stockquote.wsdl" xmlns : xsd1 = "http://example.com/stockquote.xsd" xmlns : soap = "http://schemas.xmlsoap.org/wsdl/soap/" xmlns = "http://schemas.xmlsoap.org/wsdl/" > < types > < schema targetNamespace = "http://example.com/stockquote.xsd" xmlns = "http://www.w3.org/2000/10/XMLSchema" > < element name = "TradePriceRequest" > < complexType > < all > < element name = "tickerSymbol" type = "string" / > < / all > < / complexType > < / element > < element name = "TradePrice" > < complexType > < all > < element name = "price" type = "float" / > < / all > < / complexType > < / element > < / schema > < / types > < message name = "GetLastTradePriceInput" > < part name = "body" element = "xsd1:TradePriceRequest" / > < / message > < message name = "GetLastTradePriceOutput" > < part name = "body" element = "xsd1:TradePrice" / > < / message > < portType name = "StockQuotePortType" > < operation name = "GetLastTradePrice" > < input message = "tns:GetLastTradePriceInput" / > < output message = "tns:GetLastTradePriceOutput" / > < / operation > < / portType > < binding name = "StockQuoteSoapBinding" type = "tns:StockQuotePortType" > < soap : binding style = "document" transport = "http://schemas.xmlsoap.org/soap/http" / > < operation name = "GetLastTradePrice" > < soap : operation soapAction = "http://example.com/GetLastTradePrice" / > < input > < soap : body use = "literal" / > < / input > < output > < soap : body use = "literal" / > < / output > < / operation > < / binding > < service name = "StockQuoteService" > < documentation > My first service < / documentation > < port name = "StockQuotePort" binding = "tns:StockQuoteBinding" > < soap : address location = "http://example.com/stockquote" / > < / port > < / service > < / definitions > |

Contoh SOAP 2.0 WSDL:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
< ! -- Crunchify ' s example of WSDL 2.0 -- > <? xml version = "1.0" encoding = "UTF-8" ?> < definitions xmlns = "http://www.w3.org/ns/wsdl" xmlns : tns = "http://www.tmsws.com/wsdl20sample" xmlns : whttp = "http://schemas.xmlsoap.org/wsdl/http/" xmlns : wsoap = "http://schemas.xmlsoap.org/wsdl/soap/" targetNamespace = "http://www.tmsws.com/wsdl20sample" > < ! -- Abstract type -- > < types > < xs : schema xmlns : xs = "http://www.w3.org/2001/XMLSchema" xmlns = "http://www.tmsws.com/wsdl20sample" targetNamespace = "http://crunchify.com/wsdl20" > < xs : element name = "request" > . . . add your code here . . . < / xs : element > < xs : element name = "response" > . . . add your code here . . . < / xs : element > < / xs : schema > < / types > < ! -- Abstract interfaces -- > < interface name = "CrunchifyItem" > < fault name = "ErrorDescription" element = "tns:response" / > < operation name = "Get" pattern = "http://www.w3.org/ns/wsdl/in-out" > < input messageLabel = "In" element = "tns:request" / > < output messageLabel = "Out" element = "tns:response" / > < / operation > < / interface > < ! -- Concrete Binding Over HTTP -- > < binding name = "HttpBinding" interface = "tns:CrunchifyItem" type = "http://www.w3.org/ns/wsdl/http" > < operation ref = "tns:Get" whttp : method = "GET" / > < / binding > < ! -- Concrete Binding with SOAP -- > < binding name = "SoapBinding" interface = "tns:CrunchifyItem" type = "http://www.w3.org/ns/wsdl/soap" wsoap : protocol = "http://www.w3.org/2003/05/soap/bindings/HTTP/" wsoap : mepDefault = "http://www.w3.org/2003/05/soap/mep/request-response" > < operation ref = "tns:Get" / > < / binding > < ! -- Web Service offering endpoints for both bindings -- > < service name = "ServiceOne" interface = "tns:CrunchifyItem" > < endpoint name = "HttpEndpoint" binding = "tns:HttpBinding" address = "http://www.example.com/rest/" / > < endpoint name = "SoapEndpoint" binding = "tns:SoapBinding" address = "http://crunchify.com/soap/" / > < / service > < / definitions > |
Pola Desain Pabrik dijelaskan dengan Contoh.

Beri tahu saya jika Anda memiliki pertanyaan.