Download presentation
Presentation is loading. Please wait.
Published byDylan Blake Modified over 9 years ago
1
Government Data Integration หลักสูตรเบื้องต้นSOAP songrit@gmail.com 083-788-7769 1
2
วัตถุประสงค์ เข้าใจสถาปัตยกรรม SOA เข้าใจ Web Services พัฒนา Web Services แบบ SOAP 2
3
SOAP Simple Object Access Protocol 3
4
Simple Object Access Protocol (SOAP)? SOAP is an XML notation for describing how messages are assembled and transmitted over HTTP between service consumers (clients) and service providers (servers) 4
5
The Web Services Stack XML Based Messaging Network Service Description Service Publication Service Discovery Service Flow SecurityManagementQuality of Service WSFL WSDL SOAP http, ftp, MQ, IIOP, etc. UDDI 5
6
Server SOAP Server responds in SOAP format Client SOAP Client sends request in SOAP format request respond 6
7
SOAP Simple Object Access Protocol Used to send messages between applications Envelope with Header and Body Invocation of methods 7
8
8
9
9
10
WSDL Web Service Description Language ความรู้เบื้องต้นเกี่ยวกับ Web Services 10
11
Uniform Resource Identifier URI - Uniform Resource Identifier URL - Uniform Resource Locator URN - Uniform Resource Name 11
12
WSDL 12
13
WSDL... 13
14
definition 14
15
message 15
16
portType 16
17
binding <soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http'/> <soap:body use='encoded' namespace='urn:localhost-temperature' encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/> <soap:body use='encoded' namespace='urn:localhost-temperature' encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/> 17
18
service 18
19
19
20
SOAP Consumer 20
21
Google Search http://code.google.com/apis/soapsearch/ License Key –ecDc6bFQFHLXPKTEO0McWIoE3LVRSEw2 http://api.google.com/GoogleSearch.wsdl 21
22
Controller class CodeController < ApplicationController def googletest yourkey = 'YOUR GOOGLE DEVELOPER KEY' @yourquery = 'SEARCH TEXT' XSD::Charset.encoding = 'UTF8' googleurl = "http://api.google.com/search/beta2" urn = "urn:GoogleSearch" driver = SOAP::RPC::Driver.new(googleurl, urn) driver.add_method('doGoogleSearch', 'key', 'q', 'start', 'maxResults', 'filter', 'restrict', 'safeSearch', 'lr', 'ie', 'oe') @result = driver.doGoogleSearch(yourkey, @yourquery, 0, 3, false, '', false, '', '', '') end 22
23
View Query for: Found: Query took about seconds Title: Summary: Link: "> 23
24
use WSDL require 'soap/wsdlDriver' class CodeController < ApplicationController def googletest yourkey = 'YOUR GOOGLE DEVELOPER KEY' @yourquery = 'SEARCH TEXT' XSD::Charset.encoding = 'UTF8' wsdl = "http://api.google.com/GoogleSearch.wsdl" driver = SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver @result = driver.doGoogleSearch(yourkey, @yourquery, 0, 3, false, '', false, '', '', '') end 24
25
ปตท. http://www.pttplc.com/pttinfo.asmx?op=Cu rrentOilPrice http://www.pttplc.com/pttinfo.asmx?wsdl 25
26
Controller def ptt require 'soap/wsdlDriver' XSD::Charset.encoding = 'UTF8' wsdl = "http://www.pttplc.com/pttinfo.asmx?wsdl" driver = SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver @result = driver.CurrentOilPrice(:Language=>'TH') @h= Hash.from_xml @result['CurrentOilPriceResult'] end 26
27
View price is 27
28
PHP & Java http://www.blognone.com/node/4173 28
29
Lab http://www.webservicex.net/CurrencyConv ertor.asmxhttp://www.webservicex.net/CurrencyConv ertor.asmx 29
30
SOAP Provider 30
31
ActionWebService sudo gem install datanoise-actionwebservice --source http://gems.github.com ruby setup.rb 31
32
Generate Web Service ruby script/generate web_service test_ws 32
33
test_ws_api.rb class TestWsApi < ActionWebService::API::Base api_method :dogreeting, :expects => [{:username => :string}], :returns => [{:greeting => :string}] end 33
34
test_ws_controller.rb class TestWsController < ApplicationController require 'action_web_service' web_service_api 'TestWs' wsdl_service_name 'TestWs' def dogreeting(username) "Hello #{username}" end 34
35
Consumption Test (on different port) def test_soap require 'soap/wsdlDriver' XSD::Charset.encoding = 'UTF8' wsdl = "http://localhost:3999/test_ws/wsdl" driver = SOAP::WSDLDriverFactory. new(wsdl).create_rpc_driver @result = driver.dogreeting('songrit') render :text => @result end 35
36
More Parameters class PersonAPI < ActionWebService::API::Base api_method :add, :expects => [:string, :string, :bool], :returns => [:int] api_method :remove, :expects => [:int], :returns => [:bool] end 36
37
Complex Structure & Array http://doiop.com/aws_sample 37
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.