Web Service

[References to http://www.w3school.com, http://www.w3.org/TR/wsdl]

What are Web Services?

  • Web services are application components
  • Web services communicate using open protocols
  • Web services are self-contained and self-describing
  • Web services can be discovered using UDDI
  • Web services can be used by other applications
  • XML is the basis for Web services

Web services platform elements

  • SOAP (Simple Object Access Protocol)
  • UDDI (Universal Description, Discovery and Integration)
  • WSDL (Web Services Description Language)

The body of the http:
None.gif Example  1  SOAP  1.1  Request / Response via HTTP
None.gif
None.gif
<? xml version = " 1.0 " ?>
None.gif
< definitions name = " StockQuote "
None.gif
None.giftargetNamespace
= " http://example.com/stockquote.wsdl "
None.gif          xmlns:tns
= " http://example.com/stockquote.wsdl "
None.gif          xmlns:xsd1
= " http://example.com/stockquote.xsd "
None.gif          xmlns:soap
= " http://schemas.xmlsoap.org/wsdl/soap/ "
None.gif          xmlns
= " http://schemas.xmlsoap.org/wsdl/ " >
None.gif
None.gif    
< types >
None.gif       
< schema targetNamespace = " http://example.com/stockquote.xsd "
None.gif              xmlns
= " http://www.w3.org/2000/10/XMLSchema " >
None.gif           
< element name = " TradePriceRequest " >
None.gif              
< complexType >
None.gif                  
< all >
None.gif                      
< element name = " tickerSymbol "  type = " string " />
None.gif                  
</ all >
None.gif              
</ complexType >
None.gif           
</ element >
None.gif           
< element name = " TradePrice " >
None.gif              
< complexType >
None.gif                  
< all >
None.gif                      
< element name = " price "  type = " float " />
None.gif                  
</ all >
None.gif              
</ complexType >
None.gif           
</ element >
None.gif       
</ schema >
None.gif    
</ types >
None.gif
None.gif    
< message name = " GetLastTradePriceInput " >
None.gif        
< part name = " body "  element = " xsd1:TradePriceRequest " />
None.gif    
</ message >
None.gif
None.gif    
< message name = " GetLastTradePriceOutput " >
None.gif        
< part name = " body "  element = " xsd1:TradePrice " />
None.gif    
</ message >
None.gif
None.gif    
< portType name = " StockQuotePortType " >
None.gif        
< operation name = " GetLastTradePrice " >
None.gif           
< input message = " tns:GetLastTradePriceInput " />
None.gif           
< output message = " tns:GetLastTradePriceOutput " />
None.gif        
</ operation >
None.gif    
</ portType >
None.gif
None.gif    
< binding name = " StockQuoteSoapBinding "  type = " tns:StockQuotePortType " >
None.gif        
< soap:binding style = " document "  transport = " http://schemas.xmlsoap.org/soap/http " />
None.gif        
< operation name = " GetLastTradePrice " >
None.gif           
< soap:operation soapAction = " http://example.com/GetLastTradePrice " />
None.gif           
< input >
None.gif               
< soap:body use = " literal " />
None.gif           
</ input >
None.gif           
< output >
None.gif               
< soap:body use = " literal " />
None.gif           
</ output >
None.gif        
</ operation >
None.gif    
</ binding >
None.gif
None.gif    
< service name = " StockQuoteService " >
None.gif        
< documentation > My first service </ documentation >
None.gif        
< port name = " StockQuotePort "  binding = " tns:StockQuoteBinding " >
None.gif           
< soap:address location = " http://example.com/stockquote " />
None.gif        
</ port >
None.gif    
</ service >
None.gif
None.gif
</ definitions >
None.gif
None.gif

WSDL:
None.gif A WSDL document  is  simply a  set  of definitions. There  is  a definitions element at the root, and definitions inside. The grammar  is   as  follows:
None.gif
None.gif
< wsdl:definitions name = " nmtoken " ?  targetNamespace = " uri " ?>
None.gif
None.gif    
< import  namespace = " uri "  location = " uri " />*
None.gif
None.gif    
< wsdl:documentation dot.gif />   ?
None.gif
None.gif    
< wsdl:types >   ?
None.gif        
< wsdl:documentation dot.gif />?
None.gif        
< xsd:schema dot.gif />*
None.gif        
<--  extensibility element  -->   *
None.gif    
</ wsdl:types >
None.gif
None.gif    
< wsdl:message name = " nmtoken " >   *
None.gif        
< wsdl:documentation dot.gif />?
None.gif        
< part name = " nmtoken "  element = " qname " ?  type = " qname " ?/>   *
None.gif    
</ wsdl:message >
None.gif
None.gif    
< wsdl:portType name = " nmtoken " >*
None.gif        
< wsdl:documentation dot.gif />?
None.gif        
< wsdl:operation name = " nmtoken " >*
None.gif           
< wsdl:documentation dot.gif />   ?
None.gif           
< wsdl:input name = " nmtoken " ?  message = " qname " >?
None.gif               
< wsdl:documentation dot.gif />   ?
None.gif           
</ wsdl:input >
None.gif           
< wsdl:output name = " nmtoken " ?  message = " qname " >?
None.gif               
< wsdl:documentation dot.gif />   ?
None.gif           
</ wsdl:output >
None.gif           
< wsdl:fault name = " nmtoken "  message = " qname " >   *
None.gif               
< wsdl:documentation dot.gif />   ?
None.gif           
</ wsdl:fault >
None.gif        
</ wsdl:operation >
None.gif    
</ wsdl:portType >
None.gif
None.gif    
< wsdl:binding name = " nmtoken "  type = " qname " >*
None.gif        
< wsdl:documentation dot.gif />?
None.gif        
<--  extensibility element  -->   *
None.gif        
< wsdl:operation name = " nmtoken " >*
None.gif           
< wsdl:documentation dot.gif />   ?
None.gif           
<--  extensibility element  -->   *
None.gif           
< wsdl:input >   ?
None.gif               
< wsdl:documentation dot.gif />   ?
None.gif               
<--  extensibility element  -->
None.gif           
</ wsdl:input >
None.gif           
< wsdl:output >   ?
None.gif               
< wsdl:documentation dot.gif />   ?
None.gif               
<--  extensibility element  -->   *
None.gif           
</ wsdl:output >
None.gif           
< wsdl:fault name = " nmtoken " >   *
None.gif               
< wsdl:documentation dot.gif />   ?
None.gif               
<--  extensibility element  -->   *
None.gif           
</ wsdl:fault >
None.gif        
</ wsdl:operation >
None.gif    
</ wsdl:binding >
None.gif
None.gif    
< wsdl:service name = " nmtoken " >   *
None.gif        
< wsdl:documentation dot.gif />?
None.gif        
< wsdl:port name = " nmtoken "  binding = " qname " >   *
None.gif           
< wsdl:documentation dot.gif />   ?
None.gif           
<--  extensibility element  -->
None.gif        
</ wsdl:port >
None.gif        
<--  extensibility element  -->
None.gif    
</ wsdl:service >
None.gif
None.gif    
<--  extensibility element  -->   *
None.gif
None.gif
</ wsdl:definitions >
None.gif
None.gif

Services are defined using six major elements:

  • types, which provides data type definitions used to describe the messages exchanged.
  • message, which represents an abstract definition of the data being transmitted. A message consists of logical parts, each of which is associated with a definition within some type system.
  • portType, which is a set of abstract operations. Each operation refers to an input message and output messages.
  • binding, which specifies concrete protocol and data format specifications for the operations and messages defined by a particular portType.
  • port, which specifies an address for a binding, thus defining a single communication endpoint.
  • service, which is used to aggregate a set of related ports.

You can put the Web Service on your site.

None.gif < form target = " _blank "  action = ' http://www.w3schools.com
None.gif
/ webservices / tempconvert.asmx / FahrenheitToCelsius '  
None.gif
method = " POST " >  
None.gif
< table >
None.gif    
< tr >
None.gif        
< td > Fahrenheit to Celsius: </ td >
None.gif        
< td >< input  class = " frmInput "  type = " text "  
None.gif        size
= " 30 "  name = " Fahrenheit " ></ td >
None.gif    
</ tr >
None.gif    
< tr >
None.gif        
< td ></ td >
None.gif        
< td align = " right " >   < input type = " submit "  
None.gif        value
= " Submit "   class = " button " ></ td >
None.gif    
</ tr >
None.gif
</ table >
None.gif
</ form >
None.gif

转载于:https://www.cnblogs.com/ellipse-gao/archive/2007/05/26/760725.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值