Professional Documents
Culture Documents
Sinh vin: Bi Hong c Trn Tun Anh on Vit Dng Phm Hong Tin Ging vin: TS. V Th Hng Giang
Cu trc ca 1 vn bn WSDL
<types>
<types>: optional, cung cp nh ngha cc kiu d liu c s dng cc thng ip. Cc nh ngha kiu d liu thng c vit trong h thng XSD(extensible schema definition).
V d <types>
S dng 1 XSD bn ngoi <types> <xsd:schema> <xsd:import namespace="http://eg/" schemaLocation="HelloService_schema1.xsd" /> </xsd:schema> </types> Nu khng c kiu no c nh ngha trong type: <types />
<message>
nh ngha cc thng ip s dng trong web service. Th t ca cc message phn nh cch hot ng ca web service: request/response hay solicit/response. Tn ca cc message c dng ---In/---Out; --Request/---Response vi --- phn nh operation lin kt vi message.
<portType>
biu din dch v nh l mt tp named operation, mi operation c m t bi cc input/output message . N ging nh l mt interface trong ngn ng Java: cho bit cc operation v message nhng khng cho bit ci t bn trong. <portType> {<operation> <input message=...> <output message=...> </operation>} </portType> Phn ... l mt datatype trong mt namespace no . Phn trong {} c lp li nhiu ln v trong cc element c nhiu attribute.
<binding>
M t cc chi tit r rng ca web service. N ging nh l lp ci t mt interface trong Java.
<binding> <soap:binding ... /> {<operation> <soap:operation ... /> <input> <soap:input> </input> <output> <soap:output> </output> </operation> } </binding>
Attributes of <binding>
style: nhn gi tr rpc hoc document. rpc ngha l cc phn trong message ch s dng cc kiu d liu c bn c sn trong namespace http://www.w3.org/2001/XMLSchema . Gi tr document ngha l cc message c s dng cc element c nh ngha bi ngi s dng. use : nhn gi tr literal hoc encoded. Gi tr literal ngha l nh ngha kiu d liu ca service theo ng nguyn vn XML schema ca WSDL, cn gi tr encoded ngha l l nh ngha kiu d liu ca service theo cc lut m ha no , thng l cc lut m ha trong c t SOAP 1.1. Vic s dng encoded l khng tng thch chun WS-I nn t c s dng.
<service>
nh ngha mt hoc nhiu endpoint m service hot ng. Mt endpoint c m t l mt URL m cc message c th gi ti m s dng dch v. Service s lit k mt hoc nhiu port, mi port gm mt portType (interface) v mt binding(implementation). <service name=...> <port name=... binding=...> <soap:address location=... /> </port> </service> Thut ng port l ly t giao thc TCP, trong , mt kt ni c m t bi mt cp <IPAddress, PortNumber>, mi port ti mt IPAdress s phc v mt dch v nht nh.
SOAP
SOAP l giao thc c dng m cc web service lin lc c vi nhau. SOAP c 2 phin bn: SOAP 1.1(nm 2000, trong , SOAP l vit tt ca Simple Object Access Protocol), SOAP 1.2(nm 2003, trong , SOAP tr thnh danh t ring). a s cc web service m em gp (nh AmazonWebService) u c h tr cc giao thc SOAP 1.1 bn cnh SOAP1.2, HTTP GET, HTTP POST.
SOAP messages
<GetDownloadURLResult>http://www.youtube.com/get_video?video_id=Z4t8LrU STMo&l=255&sk=HHKkhrTi_MBfwyOl9RjxYrKsN2Fgd4wC&fm t_map=35%2F640000%2F9%2F0%2F115%2C34%2F0%2F9%2F0%2F115%2C5 %2F0%2F7%2F0%2F0&t=vjVQa1PpcFNF57VeqNKmEadvgzruTu8xpwNR MkWPI%3D&hl=en&plid=AARsgq_hLYy9qaVM&keywords=NA SA%252CShuttle%252CRSS%2520Retraction&cr=US </GetDownloadURLResult> </GetDownloadURLResponse> </soap:Body> </soap:Envelope>
V d minh ha
Pht trin 1 web service Encrypt
C 1 phng thc l int getEncryptionNumber(String str) Tr li 1 m ha tng ng ca 1 xu.
C ch hot ng
Mi ln web application c initialized, WSServletContextListener s c sun-jaxws.xml v to ra 1 java.util.List cc objects RuntimeEndpointInfo. Sau , n gi deploy() method ca tng object to ra 1 RuntimeModel s dng RuntimeModeler. Tc l: RuntimeModeler to ra 1 runtime model ca 1 SEI (portClassservice endpoint interface) lp ci t Web service endpoint. Mi RuntimeModel l mt model ca a web service v c th x l c cc request n
Web service