国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Home Backend Development PHP Tutorial php學(xué)習(xí)之道:WSDL詳解(1)

php學(xué)習(xí)之道:WSDL詳解(1)

Jun 13, 2016 pm 12:01 PM
gt lt nbsp quot

php學(xué)習(xí)之道:WSDL詳解(一)

WSDL文檔使用web服務(wù)描述語言來定義服務(wù)。

文檔包括邏輯(抽象)部分和具體部分。

抽象部分用于定義獨(dú)立于實(shí)現(xiàn)的數(shù)據(jù)類型和消息,具體部分定義一個endpoint如何實(shí)現(xiàn)一個可以與外界進(jìn)行交互的服務(wù)。

通常建議在寫代碼前定義WSDL文檔和XML schema,但是這就要求對WSDL非常熟悉。

邏輯部分:

包括types,message以及portType元素。types元素中,xml schema用來定義組成消息的數(shù)據(jù)的結(jié)構(gòu)。一定數(shù)量的消息元素用來定義服務(wù)所用消息的格式。portType元素包括一個或多個operation元素,用來定義被operation發(fā)送的消息。

具體部分:

包括binding和service元素。binding元素描述message元素描述的那些數(shù)據(jù)單元如何映射到一個具體的數(shù)據(jù)格式。Service元素包括一個或多個port元素,這些port元素用于定義endpoint。

總體上來說,一個WSDL文檔有以下元素組成:

  • definitions--WSDL文檔的根元素,該元素的屬性指明了wsdl文檔的名稱,文檔的目標(biāo)名字空間,以及WSDL文檔應(yīng)用的名字空間的速記定義。
  • types--數(shù)據(jù)單元的xml樣式定義,形成了服務(wù)所用消息的構(gòu)建塊。
  • portType---描述服務(wù)邏輯接口的operation元素的集合。
  • operation--一個服務(wù)包含的操作的描述,當(dāng)操作被調(diào)用時,操作被定義為兩個endpoint之間的消息傳遞。
  • binding---一個endpoint的實(shí)際數(shù)據(jù)格式說明,一個binding元素定義如何將一個抽象消息映射到一個具體數(shù)據(jù)格式。該元素指明諸如參數(shù)順序,返回值等信息。
  • service---相關(guān)port元素的集合,這些元素被庫藏,用戶組織endpoint定義。
  • port--通過binding和物理地址定義的endpoint,這個元素將所有抽象定義聚集在一起。

設(shè)計一個WSDL的步驟:

1.定義服務(wù)用到的data types

2.定義服務(wù)用到的消息

3.定義服務(wù)接口

4.定義消息與接口之間的bindings和線上數(shù)據(jù)的具體呈現(xiàn)方式

5.定義每個服務(wù)的傳輸細(xì)節(jié)。

下面根據(jù)每步展開論述:

1.定義邏輯數(shù)據(jù)單元

?? 定義一個服務(wù)時,第一件事情,你必須考慮的是作為暴露到外部的參數(shù)所用到的數(shù)據(jù),將怎樣呈現(xiàn)。與那些是選用固定數(shù)據(jù)結(jié)構(gòu)編碼的程序不同,服務(wù)必須定義出他們的數(shù)據(jù)以邏輯單元的形式,這包括兩步:

? 1.1將數(shù)據(jù)拆分成邏輯單元,這些單元能被映射為數(shù)據(jù)類型,并被服務(wù)的物理實(shí)現(xiàn)所引用。

?????? 如果你定義了一個服務(wù)接口,并且該接口已經(jīng)實(shí)現(xiàn),你必須將實(shí)現(xiàn)操作的數(shù)據(jù)類型轉(zhuǎn)換成xml元素,用于組裝成消息。如果你從頭開始,你必須定義你的消息構(gòu)建時用到的構(gòu)建塊,這樣的話,他們從實(shí)施角度看才有意義。

????? 注1:定義服務(wù)數(shù)據(jù)單元可用的類型體系:根據(jù)WSDL規(guī)范,你可以使用任何類型體系。然而在W3C規(guī)范中定義的XML schema是首選的規(guī)范的類型體系。因此,XML架構(gòu)在Apache?CXF的內(nèi)在類型系統(tǒng)。

???? 注2:xml schema:xml schema被用來定義一個xml文檔如何構(gòu)建,用于定義一個文檔由哪些元素組成。這些元素可以使用xml schema類型,比如xsd:int的或者他可以使用用戶定義的類型,用戶定義類型也是使用xml元素的組合來構(gòu)建的餓,或者他們是用嚴(yán)格的已存在類型構(gòu)建。通過結(jié)合類型定義和元素定義,你可以創(chuàng)建復(fù)雜的XML文檔可以包含復(fù)雜的數(shù)據(jù)。當(dāng)定義服務(wù)使用的數(shù)據(jù)單元時,你可以定義他們作為類型,這些類型指明消息組成部分的結(jié)構(gòu),你也能夠定義你的消息單元作為組成消息結(jié)構(gòu)的元素。

??? 注3:生成數(shù)據(jù)單元的考慮:你可以考慮簡單地生成邏輯數(shù)據(jù)單元,這些單元直接映射你在服務(wù)中使用的數(shù)據(jù)類型。當(dāng)以這個方式工作時,必須緊密遵循構(gòu)建RPC類型應(yīng)用程序的構(gòu)建模型,這不是構(gòu)建面向服務(wù)架構(gòu)程序必須的策略。webservice組織提供了一定數(shù)量的手冊來定義數(shù)據(jù)單元,另外W3C也提供了下main的手冊來教你如何使用xml schema展現(xiàn)數(shù)據(jù)類型。

? 1.2將數(shù)據(jù)單元(data units)添加到文檔

?????? 依賴于你如何選擇去生成WSDL文檔,生成新的數(shù)據(jù)定義要求有大量的知識,CXF GUI工具提供一定數(shù)量的幫助來描述數(shù)據(jù)類型。其他的xml編輯器提供不同級別的幫助。不論你選擇哪種編輯器,擁有一些與文檔相關(guān)的知識是很重要的。

?????? 定義WSDL中用到的數(shù)據(jù),需以下步驟:

?????? a.確定接口要用到的所有數(shù)據(jù)單元

?????? b.在文檔中生成一個types元素。

?????? c.創(chuàng)建一個schema元素,作為types元素的子元素

?????? d.complex類型是元素的集合,使用complexType元素來定義數(shù)據(jù)類型

?????? e.對于每個數(shù)組來說,定義他的數(shù)據(jù)類型也使用complexType元素

?????? f.對于每個復(fù)雜類型來說,都可以從簡單類型衍生出來,定義數(shù)據(jù)局類型可以通過simpleType元素。

???????g.對于每個枚舉類型,定義數(shù)據(jù)類型使用simpleType元素。

?????? h.對于每個元素來說,定義他們使用element元素。

1.3 xml Schema simple types:

?????? 如果一個消息組件是簡單類型的話,那么就不需要給他定義一個類型。接口使用的復(fù)雜類型也是通過簡單類型定義的。

????? 注1:輸入簡單類型:xml簡單類型是主要的放置元素,在element元素中。簡單類型也被使用在restriction元素和extension元素的base屬性中。簡單類型總是使用xsd作為前綴,例如,為了指明類型int,你將輸入xsd:int在type屬性中。

??? CXF支持下列xml schema簡單類型:xsd:string,xsd:normalizedString,xsd:int,xsd:base64Binary等。

1.4定義復(fù)雜數(shù)據(jù)類型:

???? xml schema提供靈活和強(qiáng)大的機(jī)制來構(gòu)建負(fù)責(zé)數(shù)據(jù)結(jié)構(gòu)。你可以創(chuàng)建數(shù)據(jù)結(jié)構(gòu)通過創(chuàng)建一個元素和屬性的序列。你看可以擴(kuò)展已有類型來創(chuàng)建更復(fù)雜的類型。

??? 另外,為了構(gòu)建復(fù)雜數(shù)據(jù)結(jié)構(gòu),你可以描述特定的類型,諸如:枚舉類型。數(shù)據(jù)類型中的數(shù)據(jù)有一個特定的取值范圍,或者數(shù)據(jù)類型的數(shù)值必須遵循某種特定的模式,通過擴(kuò)展或者限制原始類型。

1.5定義數(shù)據(jù)結(jié)構(gòu):

??? 在xml schema中,數(shù)據(jù)單元是數(shù)據(jù)域的集合,這些數(shù)據(jù)域是通過負(fù)責(zé)類型元素定義的。指明一個復(fù)雜的類型需要三塊信息:

??? a.復(fù)雜元素的名稱需要被指定。

??? b.復(fù)雜類型的第一個子元素用來描述該結(jié)構(gòu)的域的行為,當(dāng)他被放入線上時。

??? c.每個結(jié)構(gòu)中的域,都被用element元素定義。

??? 下面的雷子是一個復(fù)雜類型有兩個子元素:

????????????? 結(jié)構(gòu)如下:

<div style="text-align:left">struct personalInfo</p>{  string name;<div style="text-align:left"></p>  int age;<div style="text-align:left"></p>};

對應(yīng)的WSDL文檔:

<div style="text-align:left"><complexType name="personalInfo"></p>  <sequence><div style="text-align:left">name="name" type="xsd:string" />    <element</p>    <element  name="age" type="xsd:int" />  </sequence><div style="text-align:left"></p></complexType>

注1:復(fù)雜類型的種類:

xml schema有三種方式描述當(dāng)xml文檔被展現(xiàn)并通過線上展示時,其中的域如何被組織。第一個子元素確定哪種復(fù)雜類型被引用。下面展示了用來定義復(fù)雜類型行為的三種方式:

  • sequence:所有的復(fù)雜類型域必須被顯示,并且他們必須有一個確定的次序,該次序與類型定義的次序相同。
  • all:所有的復(fù)雜類型域都需要有,但是次序無所謂
  • choice:僅僅是元素中一個可以出現(xiàn)在消息中。

注2:定義結(jié)構(gòu)的部分:

你定義數(shù)據(jù)域,這些數(shù)據(jù)域是由一個結(jié)構(gòu)體組成。每個復(fù)雜類型元素應(yīng)該包括至少一個element元素。每個element元素對應(yīng)已經(jīng)定義的數(shù)據(jù)結(jié)構(gòu)中的一個域。

為了充分描述數(shù)據(jù)結(jié)構(gòu)中的域,element必須有兩個屬性:

name屬性:指明數(shù)據(jù)域的名稱并且是唯一的

type屬性:指明該域存儲的數(shù)據(jù)的類型??梢允呛唵晤愋鸵部梢允菑?fù)雜類型。

除此而外還有兩個重要屬性:minOccurs和maxOccurs,這個屬性用來設(shè)置該域在結(jié)構(gòu)中發(fā)生的次數(shù)上下限。缺省情況下每個字段值發(fā)生一次。使用這些屬性,你可以改變結(jié)構(gòu)體中一個域發(fā)生的次數(shù)。下面的例子中,previousJobs最少發(fā)生一次,最多7次。

<div style="text-align:left"><complexType name="personalInfo></p>  <all><div style="text-align:left">ment name="name" type="xsd:string"/>    <el</p>    <eleement name="age" type="xsd:int"/><div style="text-align:left">pe="xsd:string:             minOccurs="3" maxOccu</p>    <element name="previousJobs" tyrs="7"/>  </all><div style="text-align:left"></p></complexType>

注3:定義屬性:在xml文檔中,屬性被包含在element內(nèi)部的。例如在complexType元素中name就是屬性,它通常跟在,等元素的后面。例如:

<div style="text-align:left"><complexType name="personalInfo></p>  <all><div style="text-align:left">ment name="name" type="xsd:string"/>    <el</p>    <eleement name="previousJobs" type="xsd:string"<div style="text-align:left"></all>  <attribute name="age" type="xsd:i</p>             minOccurs="3" maxOccurs="7"/>  nt" use="optional" /><div style="text-align:left"></p></complexType>

1.6定義數(shù)組

CXF支持兩種方式來定義數(shù)組,第一種是定義一個復(fù)雜類型,采用簡單元素,他的最大發(fā)生屬性是個大于1的值,第二種方式是使用SOAP數(shù)組,SOAP數(shù)組提供增加的功能,比如ability來簡化定義多為數(shù)組并且發(fā)送分離后的數(shù)組。

復(fù)合類型數(shù)組:復(fù)合類型數(shù)組是特殊的sequence復(fù)合類型。你可以簡單定義一個復(fù)合類型通過簡單元素,并且制定該元素的最大發(fā)生maxOccurs屬性。例如,定義一個數(shù)組,擁有二個浮點(diǎn)數(shù)字,你可以使用復(fù)合類型如下:

<div style="text-align:left"><complexType name="personalInfo></p><div style="text-align:left">  <element name="averages" type="xsd:float" maxOccurs="20"/></p><div style="text-align:left"></complexType></p>

你也可以定義一個最小發(fā)生屬性。

SOAP數(shù)組:SOAP數(shù)組定義通過SOAP-ENC:Array,該類型基于wsdl:arrayType元素。

<div style="text-align:left"><complexType name="<span class="replaceable" style="padding:0px; margin:0px"><code style="padding:0px; margin:0px"><span style="font-family:NSimsun; padding:0px; margin:0px">TypeName</span></code></span>"></p><div style="text-align:left">  <complexContent></p><div style="text-align:left">    <restriction base="SOAP-ENC:Array"></p><div style="text-align:left">      <attribute ref="SOAP-ENC:arrayType" </p><div style="text-align:left">                 wsdl:arrayType="<span class="replaceable" style="padding:0px; margin:0px"><code style="padding:0px; margin:0px"><span style="font-family:NSimsun; padding:0px; margin:0px">ElementType<ArrayBounds></span></code></span>"/></p><div style="text-align:left">    </restriction></p><div style="text-align:left">  </complexContent></p><div style="text-align:left"></complexType></p>

上述語法中,typename指定新定義的數(shù)組名,ElementType指定數(shù)組中元素的數(shù)據(jù)類型。ArrayBounds指定數(shù)組的維度及元素數(shù)量,單位數(shù)組通過[],多維通過[][]。

<div style="text-align:left"><complexType name="SOAPStrings"></p>  <complexContent><div style="text-align:left">se="SOAP-ENC:Array">      <attribute r</p>    <restriction baef="SOAP-ENC:arrayType"<div style="text-align:left">ayType="xsd:string[]"/>    </restriction>  </c</p>                 wsdl:arromplexContent><div style="text-align:left"></p></complexType>

1.7通過extension定義類型

類似主要的編碼語言,xml schema允許你創(chuàng)建數(shù)據(jù)類型,這些數(shù)據(jù)類型集成已有的數(shù)據(jù)類型,這種機(jī)制被稱之為:extension。例如你可以創(chuàng)建一個新類型名叫alienInfo,它集成了PersonalInfo結(jié)構(gòu),通過鄭家了新的元素planet。

extension的類型定義包括四個部分:

a.通過name屬性來定義類型名

b.通過complexContent元素來指定新類型將擁有多余一個的元素。

c.被繼承的那個類,被稱之為base類型,通過base屬性來指定。

d.新類型和屬性被定義在extension元素中。例子如下:

<div style="text-align:left"><complexType name="alienInfo"></p>  <complexContent><div style="text-align:left">="personalInfo">      <sequence> </p>    <extension base       <element name="planet" type="xsd:string"/><div style="text-align:left">nt></complexType</p>      </sequence>    </extension>  </complexCont<div style="text-align:left">e></p>

1.8通過restriction來定義類型

簡單例子

<div style="text-align:left"><simpleType name="SSN"></p><div style="text-align:left">  <restriction base="xsd:string"></p><div style="text-align:left">    <pattern value="\d{3}-\d{2}-\d{4}"/></p>  </restriction><div style="text-align:left"></p></simpleType>

1.9定義枚舉類型:

<div style="text-align:left"><simpleType name="widgetSize"></p><div style="text-align:left">  <restriction base="xsd:string"></p>    <enumeration value="big"/><div style="text-align:left">>    <enumeration value="mungo"</p>    <enumeration value="large"//>  </restriction><div style="text-align:left"></p></simpleType>

2定義元素:

在xml schema中的元素體現(xiàn)為一個元素的實(shí)例。大多數(shù)最基本的元素有簡單元素組成。像element元素,他是由一定數(shù)量的復(fù)雜類型定義的。它有三個屬性:

  • 名稱:一個需要的屬性來指明元素的名字
  • type:指明元素的類型,這個類型可以是任何xml schema的原類型或者任何已經(jīng)命名的復(fù)合類型。這個屬性屬性可以被省略,如果類型已經(jīng)內(nèi)置定義。
  • nillable:指定是否元素可以從一個文檔中忽略,如果是ture,則元素可以被任何根據(jù)該SCHEMA生成數(shù)據(jù)文件中忽略。

一個元素可以有一個內(nèi)置類型定義,內(nèi)置類型被指明,通過復(fù)合類型元素或者簡單類型元素。一旦你說明了是否數(shù)據(jù)類型是復(fù)合或者簡單,你可以定義任何你需要的數(shù)據(jù)類型。內(nèi)置類型定義建議不被使用,因?yàn)樗恢С种赜谩?/p>

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Solution: Your organization requires you to change your PIN Solution: Your organization requires you to change your PIN Oct 04, 2023 pm 05:45 PM

The message "Your organization has asked you to change your PIN" will appear on the login screen. This happens when the PIN expiration limit is reached on a computer using organization-based account settings, where they have control over personal devices. However, if you set up Windows using a personal account, the error message should ideally not appear. Although this is not always the case. Most users who encounter errors report using their personal accounts. Why does my organization ask me to change my PIN on Windows 11? It's possible that your account is associated with an organization, and your primary approach should be to verify this. Contacting your domain administrator can help! Additionally, misconfigured local policy settings or incorrect registry keys can cause errors. Right now

How to adjust window border settings on Windows 11: Change color and size How to adjust window border settings on Windows 11: Change color and size Sep 22, 2023 am 11:37 AM

Windows 11 brings fresh and elegant design to the forefront; the modern interface allows you to personalize and change the finest details, such as window borders. In this guide, we'll discuss step-by-step instructions to help you create an environment that reflects your style in the Windows operating system. How to change window border settings? Press + to open the Settings app. WindowsI go to Personalization and click Color Settings. Color Change Window Borders Settings Window 11" Width="643" Height="500" > Find the Show accent color on title bar and window borders option, and toggle the switch next to it. To display accent colors on the Start menu and taskbar To display the theme color on the Start menu and taskbar, turn on Show theme on the Start menu and taskbar

How to change title bar color on Windows 11? How to change title bar color on Windows 11? Sep 14, 2023 pm 03:33 PM

By default, the title bar color on Windows 11 depends on the dark/light theme you choose. However, you can change it to any color you want. In this guide, we'll discuss step-by-step instructions for three ways to change it and personalize your desktop experience to make it visually appealing. Is it possible to change the title bar color of active and inactive windows? Yes, you can change the title bar color of active windows using the Settings app, or you can change the title bar color of inactive windows using Registry Editor. To learn these steps, go to the next section. How to change title bar color in Windows 11? 1. Using the Settings app press + to open the settings window. WindowsI go to "Personalization" and then

How to enable or disable taskbar thumbnail previews on Windows 11 How to enable or disable taskbar thumbnail previews on Windows 11 Sep 15, 2023 pm 03:57 PM

Taskbar thumbnails can be fun, but they can also be distracting or annoying. Considering how often you hover over this area, you may have inadvertently closed important windows a few times. Another disadvantage is that it uses more system resources, so if you've been looking for a way to be more resource efficient, we'll show you how to disable it. However, if your hardware specs can handle it and you like the preview, you can enable it. How to enable taskbar thumbnail preview in Windows 11? 1. Using the Settings app tap the key and click Settings. Windows click System and select About. Click Advanced system settings. Navigate to the Advanced tab and select Settings under Performance. Select "Visual Effects"

OOBELANGUAGE Error Problems in Windows 11/10 Repair OOBELANGUAGE Error Problems in Windows 11/10 Repair Jul 16, 2023 pm 03:29 PM

Do you see "A problem occurred" along with the "OOBELANGUAGE" statement on the Windows Installer page? The installation of Windows sometimes stops due to such errors. OOBE means out-of-the-box experience. As the error message indicates, this is an issue related to OOBE language selection. There is nothing to worry about, you can solve this problem with nifty registry editing from the OOBE screen itself. Quick Fix – 1. Click the “Retry” button at the bottom of the OOBE app. This will continue the process without further hiccups. 2. Use the power button to force shut down the system. After the system restarts, OOBE should continue. 3. Disconnect the system from the Internet. Complete all aspects of OOBE in offline mode

10 Ways to Adjust Brightness on Windows 11 10 Ways to Adjust Brightness on Windows 11 Dec 18, 2023 pm 02:21 PM

Screen brightness is an integral part of using modern computing devices, especially when you look at the screen for long periods of time. It helps you reduce eye strain, improve legibility, and view content easily and efficiently. However, depending on your settings, it can sometimes be difficult to manage brightness, especially on Windows 11 with the new UI changes. If you're having trouble adjusting brightness, here are all the ways to manage brightness on Windows 11. How to Change Brightness on Windows 11 [10 Ways Explained] Single monitor users can use the following methods to adjust brightness on Windows 11. This includes desktop systems using a single monitor as well as laptops. let's start. Method 1: Use the Action Center The Action Center is accessible

Display scaling guide on Windows 11 Display scaling guide on Windows 11 Sep 19, 2023 pm 06:45 PM

We all have different preferences when it comes to display scaling on Windows 11. Some people like big icons, some like small icons. However, we all agree that having the right scaling is important. Poor font scaling or over-scaling of images can be a real productivity killer when working, so you need to know how to customize it to get the most out of your system's capabilities. Advantages of Custom Zoom: This is a useful feature for people who have difficulty reading text on the screen. It helps you see more on the screen at one time. You can create custom extension profiles that apply only to certain monitors and applications. Can help improve the performance of low-end hardware. It gives you more control over what's on your screen. How to use Windows 11

How to Fix Activation Error Code 0xc004f069 in Windows Server How to Fix Activation Error Code 0xc004f069 in Windows Server Jul 22, 2023 am 09:49 AM

The activation process on Windows sometimes takes a sudden turn to display an error message containing this error code 0xc004f069. Although the activation process is online, some older systems running Windows Server may experience this issue. Go through these initial checks, and if they don't help you activate your system, jump to the main solution to resolve the issue. Workaround – close the error message and activation window. Then restart the computer. Retry the Windows activation process from scratch again. Fix 1 – Activate from Terminal Activate Windows Server Edition system from cmd terminal. Stage – 1 Check Windows Server Version You have to check which type of W you are using

See all articles