摘要:本文包含了使用 Microsoft Windows XP Professional 中隨附的 SOAP 客戶端軟件來訪問使用 SOAP 的 Web 服務(wù)的基礎(chǔ)知識。本文首先簡要介紹了 SOAP 和 WSDL 標(biāo)準(zhǔn),然后討論如何實現(xiàn)與啟用 SOAP 的 Web 服務(wù)進(jìn)行通訊的客戶端。
Microsoft Windows XP Professional 包含 Microsoft SOAP Toolkit 2.0 的客戶端部分,它可以構(gòu)建 SOAP 客戶端應(yīng)用程序或?qū)?yīng)用程序分配給 Windows XP Professional 客戶端,而無需分配 SOAP Toolkit 2.0 的客戶端部分。本文包含了使用 Windows XP 中隨附的 SOAP 客戶端軟件來訪問使用 SOAP 的 Web 服務(wù)的基礎(chǔ)知識。本文首先簡要介紹了 SOAP 和 Web 服務(wù)描述語言 (WSDL) 標(biāo)準(zhǔn),然后討論如何實現(xiàn)與啟用 SOAP 的 Web 服務(wù)進(jìn)行通訊的客戶端。
SOAP 是簡單對象訪問協(xié)議的簡稱,由 http://www.w3.org/TR/SOAP 上的 SOAP 標(biāo)準(zhǔn)進(jìn)行定義。SOAP 協(xié)議定義了用于在系統(tǒng)之間進(jìn)行通訊的標(biāo)準(zhǔn) XML 消息的格式。由于該消息格式已標(biāo)準(zhǔn)化并基于 XML 標(biāo)準(zhǔn),因此可使用 SOAP 在多種計算機體系結(jié)構(gòu)、語言和操作系統(tǒng)之間進(jìn)行通訊。SOAP 啟用了一類新的應(yīng)用程序,稱為 Web 服務(wù),Web 服務(wù)以一種標(biāo)準(zhǔn)的方式公開服務(wù),以便應(yīng)用程序開發(fā)人員可以通過將 Web 上來自許多不同源的服務(wù)組合到一起,從而創(chuàng)建新的應(yīng)用程序。
SOAP 規(guī)范涵蓋了四個主要部分:一個必需的 SOAP 信封格式,定義了包圍 SOAP 消息的 XML 內(nèi)容的信封的外觀;一組可選的編碼規(guī)則,定義了如何將語言類型映射到 SOAP 消息中的 XML(由于這在此規(guī)范的第 5 節(jié)中定義,因此稱為“Section 5 編碼”);一個可選的 RPC 格式,定義了函數(shù)調(diào)用在 SOAP 消息中的表達(dá)方式;一個 HTTP 綁定,定義了如何通過 HTTP 交換 SOAP 消息。HTTP 是該標(biāo)準(zhǔn)定義的唯一通訊協(xié)議綁定;因此,幾乎所有的 SOAP 實現(xiàn)都包含 HTTP 綁定。請注意,SOAP 并不限制可用于傳輸 SOAP 消息的其他通訊協(xié)議。
以下是一個簡單的 SOAP 消息:
<?xml version="1.0" encoding="UTF-8" standalone="no"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Body> <SOAPSDK1:Add xmlns:SOAPSDK1="http://tempuri.org/message/"> <a>333</a> <b>888</b> </SOAPSDK1:Add> </SOAP-ENV:Body></SOAP-ENV:Envelope>
讓我們仔細(xì)研究一下此消息,以了解 SOAP 消息的格式。第一行是定義 SOAP 文檔中使用的字符集的 XML 聲明。Envelope 元素是必需的元素,它始終是 SOAP 消息的根,并始終位于“http://schemas.xmlsoap.org/soap/envelope/”命名空間中。
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 屬性定義了該消息中使用的編碼樣式。在此例中,使用了標(biāo)準(zhǔn)的 Section 5 編碼。Envelope 元素的 Body 子元素中包含 SOAP 消息。正如 SOAP 規(guī)范的第 7 節(jié)中定義的那樣,Add 元素表示對名為 Add 的操作的調(diào)用。Add 的子元素是 Add 方法調(diào)用的參數(shù)。
對該消息的響應(yīng)如下所示:
<?xml version="1.0" encoding="UTF-8" standalone="no"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Body> <SOAPSDK1:AddResponse xmlns:SOAPSDK1="http://tempuri.org/message/"> <Result>1221</Result> </SOAPSDK1:AddResponse> </SOAP-ENV:Body></SOAP-ENV:Envelope>
WSDL 是 Web 服務(wù)定義語言的簡稱。若要成功調(diào)用一個 Web 服務(wù),您需要了解如何獲得該服務(wù),該服務(wù)支持哪些操作,該服務(wù)需要哪些參數(shù),以及該服務(wù)所返回的內(nèi)容。WSDL 在一個可被讀取或可由機器處理的 XML 文檔中提供所有這些信息。
為了解 WSDL 文件的格式,我們來分析一下以下 WSDL 文件:
<?xml version="1.0" encoding="UTF-8" ?> <definitions name="net.xmethods.services.currencyexchange.CurrencyExchange"targetNamespace="http://www.themindelectric.com/wsdl/net.xmethods.services.currencyexchange.CurrencyExchange/" xmlns:tns="http://www.themindelectric.com/wsdl/net.xmethods.services.currencyexchange.CurrencyExchange/"xmlns:electric="http://www.themindelectric.com/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/"><message name="getRateRequest1"> <part name="country1" type="xsd:string" /> <part name="country2" type="xsd:string" /> </message><message name="getRateResponse1"> <part name="Result" type="xsd:float" /> </message><portType name="net.xmethods.services.currencyexchange.CurrencyExchangePortType"> <operation name="getRate" parameterOrder="country1 country2"> <input message="tns:getRateRequest1" /> <output message="tns:getRateResponse1" /> </operation></portType><binding name="net.xmethods.services.currencyexchange.CurrencyExchangeBinding" type="tns:net.xmethods.services.currencyexchange.CurrencyExchangePortType"><soap:binding style="rpc"transport="http://schemas.xmlsoap.org/soap/http" /> <operation name="getRate"> <soap:operation soapAction="urn:xmethods-CurrencyExchange#getRate" /> <input> <soap:body use="encoded" namespace="urn:xmethods-CurrencyExchange" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" /> </input> <output> <soap:body use="encoded" namespace="urn:xmethods-CurrencyExchange" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" /> </output> </operation></binding><service name="net.xmethods.services.currencyexchange.CurrencyExchangeService"> <documentation> net.xmethods.services.currencyexchange.CurrencyExchange web service </documentation> <port name="net.xmethods.services.currencyexchange.CurrencyExchangePort" binding="tns:net.xmethods.services.currencyexchange. CurrencyExchangeBinding"> <soap:address location="http://206.135.115.109:9090/soap" /> </port></service></definitions>
這是在 Mind Electric 的 Glue 中實現(xiàn)匯率服務(wù)的 WSDL 文件。因此,該格式不同于 Microsoft SOAP Toolkit WSDL 文件,但它是兼容的。WSDL 文件的第一個元素是 definitions 元素,它是文件的根元素且通常包含幾個命名空間聲明:
<definitions name="net.xmethods.services.currencyexchange.CurrencyExchange"targetNamespace="http://www.themindelectric.com/wsdl/ net.xmethods.services.currencyexchange.CurrencyExchange/"xmlns:tns="http://www.themindelectric.com/wsdl/ net.xmethods.services.currencyexchange.CurrencyExchange/"xmlns:electric="http://www.themindelectric.com/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/"></definitions>
請注意,xsd 命名空間是 2001 版的。SOAP 工具包默認(rèn)為 2001 Recommendation 版的 XSD 架構(gòu)命名空間,但它可以理解以舊版命名空間編寫的 WSDL 文件。
如果 WSDL 使用了任何復(fù)雜類型,則這些類型的 XSD 架構(gòu)定義將包含在<types></types> 元素中。由于該 WSDL 文件未使用任何復(fù)雜類型,因此沒有該元素。
下一部分定義了由該 WSDL 中定義的服務(wù)所使用的消息:
<message name="getRateRequest1"> <part name="country1" type="xsd:string" /> <part name="country2" type="xsd:string" /> </message><message name="getRateResponse1"> <part name="Result" type="xsd:float" /> </message>
方法參數(shù)的名稱和數(shù)據(jù)類型在此處定義。
portType 元素定義了上一部分中定義的消息和使用它們的操作之間的映射:
<portType name="net.xmethods.services.currencyexchange.CurrencyExchangePortType"> <operation name="getRate" parameterOrder="country1 country2"> <input message="tns:getRateRequest1" /> <output message="tns:getRateResponse1" /> </operation></portType>
binding 元素定義了 portType 元素中定義的抽象操作和它們在 SOAP 中的實現(xiàn)方式之間的綁定。這是一個獨立元素,因為 WSDL 可以定義其他非 SOAP 協(xié)議。這里需要注意幾點:style="rpc" 表示該消息使用 SOAP 標(biāo)準(zhǔn)的第 7 節(jié)中定義的 rpc 規(guī)則。如果指定 style="document",則 SOAP 消息的內(nèi)容將為 XML 文檔。transport 屬性表示 SOAP 消息將以 SOAP HTTP 消息的形式發(fā)送,soapAction 屬性定義了 HTTP 包中 soapAction 標(biāo)頭的內(nèi)容,use="encoded" 屬性表示參數(shù)值使用了 SOAP Section 5 編碼。
<binding name="net.xmethods.services.currencyexchange.CurrencyExchangeBinding"type="tns:net.xmethods.services.currencyexchange.CurrencyExchangePortType"><soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" /> <operation name="getRate"> <soap:operation soapAction="urn:xmethods-CurrencyExchange#getRate" /> <input> <soap:body use="encoded" namespace="urn:xmethods-CurrencyExchange" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" /> </input> <output> <soap:body use="encoded" namespace="urn:xmethods-CurrencyExchange" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" /> </output> </operation></binding>
service 元素將 SOAP 綁定與服務(wù)的物理實現(xiàn)聯(lián)系在一起。服務(wù)的 URL 就是在此處定義的。請注意,此服務(wù)的端口是 9090 — SOAP 不只是通過端口 80 工作。(如果您的防火墻要求您使用端口 80,則該服務(wù)還有一個副本運行在端口 80 上。)
<service name="net.xmethods.services.currencyexchange.CurrencyExchangeService"> <documentation> net.xmethods.services.currencyexchange.CurrencyExchange web service </documentation> <port name="net.xmethods.services.currencyexchange.CurrencyExchangePort" binding="tns:net.xmethods.services. currencyexchange.CurrencyExchangeBinding"> <soap:address location="http://206.135.115.109:9090/soap" /> </port></service>
本部分將詳細(xì)介紹使用 Windows XP 中隨附的 SOAP 客戶端來構(gòu)建簡單 SOAP 應(yīng)用程序的過程。示例中使用的 Web 服務(wù)是 XMethods 站點上的外匯匯率服務(wù),該服務(wù)是可用的 SOAP 服務(wù)的聯(lián)機列表。
該服務(wù)可接受兩個國家/地區(qū)作為參數(shù),并返回它們之間的匯率。描述該服務(wù)的 WSDL 文件位于以下位置:http://www.xmethods.net/sd/CurrencyExchangeService.wsdl。
使用高級別 SOAP API 調(diào)用此 SOAP 方法所需的步驟如下:創(chuàng)建一個 SOAPClient 對象,用 WSDL 文件初始化該 SOAPClient 對象,然后調(diào)用該方法。
以下是完成此操作的簡單 VBScript 代碼:
dim SOAPClientset SOAPClient = createobject("MSSOAP.SOAPClient")on error resume nextSOAPClient.mssoapinit("http://www.xmethods.net/sd/CurrencyExchangeService.wsdl") if err then wscript.echo SOAPClient.faultString wscript.echo SOAPClient.detail end ifwscript.echo SOAPClient.getRate("England","Japan") if err then wscript.echo SOAPClient.faultString wscript.echo SOAPClient.detail end if
三行加粗的代碼行對應(yīng)于上面提到的三個步驟。mssoapinit 的參數(shù)是一個 WSDL 文件規(guī)范,該參數(shù)可以是一個 URL(如果該 WSDL 文件位于遠(yuǎn)程系統(tǒng)上),也可以是一個文件路徑(如果該 WSDL 文件位于本地機器上)。本地 WSDL 文件更為高效,這是因為檢索文件不需要通過網(wǎng)絡(luò)往返行程。此外,還可以更輕松地管理在使用時加載到所有客戶端的單個 WSDL 文件。
要運行該 SOAP 方法,請將此代碼鍵入名為“currency.vbs”的文件,然后用“cscript currency.vbs”執(zhí)行它。結(jié)果如下所示:
C:\SOAPDemo>cscript currency.vbsMicrosoft (R) Windows Script Host Version 5.1 for WindowsCopyright (C) Microsoft Corporation 1996-1999. All rights reserved.173.9434
您應(yīng)該能夠輕松地將此代碼應(yīng)用到 VB、C++ 或其他任何已啟用 COM 的語言中。以下是在 VB 中實現(xiàn)的同一服務(wù):
Private Sub Form_Load() Dim SOAPClient As SOAPClient Set SOAPClient = New SOAPClient On Error GoTo SOAPError SOAPClient.mssoapinit _ ("http://services.xmethods.net/soap/urn:xmethods-CurrencyExchange.wsdl") MsgBox Str(SOAPClient.getRate("England", "Japan")), _ vbOKOnly, "Exchange Rate"Exit SubSOAPError: MsgBox SOAPClient.faultstring + vbCrLf + SOAPClient.detail, vbOKOnly,_ "SOAP Error"End Sub
注: Windows XP 中隨附的 SOAPClient 的版本不適于在 ASP 應(yīng)用程序中運行。要在 ASP 應(yīng)用程序中運行 SOAPClient,您必須下載完整版的 SOAP Toolkit 2.0。
現(xiàn)在,您已經(jīng)了解了如何使用 Windows XP 中的 SOAP 來構(gòu)建 Web 服務(wù)客戶端應(yīng)用程序,您可能希望擴展自己的 SOAP 知識并構(gòu)建自己的 Web 服務(wù)。您可以借助于以下兩個較好的信息源:http://msdn.microsoft.com/soap/ 和 http://msdn.microsoft.com/webservices/。這些站點包含指向 SOAP 信息、白皮書、其他 SOAP 站點以及下載頁的鏈接,您可以從下載頁下載完整的 SOAP Toolkit 2.0 以開始構(gòu)建自己的 Web 服務(wù)應(yīng)用程序。請注意,當(dāng)您安裝完整版時,將看到幾條警告,報告由于系統(tǒng)文件保護而無法覆蓋當(dāng)前文件。您可以安全地忽略這些錯誤。您還可以訪問 XMethods 并嘗試那里的更多服務(wù) — 您只需記住,為了讓 SOAP 工具包正常工作,服務(wù)必須提供 WSDL 文件。
本部分回顧了由 SOAPClient 對象公開的對象模型,并描述了由 SOAPClient 公開的每個方法和屬性。有關(guān)詳細(xì)信息,請參閱 http://msdn.microsoft.com/soap/。
![]() | 簡介 |
![]() | 什么是 SOAP? |
![]() | 什么是 WSDL? |
![]() | 構(gòu)建簡單的客戶端應(yīng)用程序 |
![]() | 后面的步驟 |
![]() | SOAPClient 對象 |
mssoapinit 方法使用 Web 服務(wù)描述語言 (WSDL) 文件作為輸入來初始化 SOAPClient 對象。在初始化過程中,所標(biāo)識服務(wù)中的所有操作都綁定到 SOAPClient 對象。因此,您可以使用 SOAPClient 對象來調(diào)用該服務(wù)中定義的操作。
方法定義
HRESULT mssoapinit( [in] BSTR bstrWSDLFile, [in, optional, defaultvalue("")] BSTR bstrServiceName, [in, optional, defaultvalue("")] BSTR bstrPort, [in, optional, defaultvalue("")] BSTR bstrWSMLFile);
參數(shù)
bstrWSDLFile bstrWSDLFile 是用于描述服務(wù)器所提供服務(wù)的 WSDL 文件的 URL。
bstrServiceName
bstrServiceName 是WSDL 文件(包含簡單對象訪問協(xié)議 (SOAP) 請求中指定操作)中的可選服務(wù)。如果該參數(shù)缺失、為空或是空字符串,則在初始化 SOAPClient 對象時,mssoapinit 方法將使用指定 WSDL 文件中的第一個服務(wù)。
bstrPort
bstrPort(也是可選的)是包含 SOAP 請求中指定操作的 WSDL 文件中的端口名稱。如果該參數(shù)缺失、為空或是空字符串,則在初始化 SOAPClient 對象時,mssoapinit 方法將使用指定服務(wù)中的第一個端口。
bstrWSMLFile(也可選)是 Web 服務(wù)元語言 (WSML) 文件的 URL。該參數(shù)僅在使用自定義類型映射器時才是必需的。
Visual Basic 語法
Sub mssoapinit(bstrWSDLFile As String,_ [bstrServiceName As String],_ [bstrPort As String],_ [bstrWSMLFile As String])
Visual Basic 示例
set soapclient = CreateObject("MSSOAP.SOAPClient") call soapclient.mssoapinit("DocSample1.wsdl", "", "", "")wscript.echo soapclient.AddNumbers(2,3)wscript.echo soapclient.SubtractNumbers(3,2)
備注
mssoapinit 方法是客戶端高級別 API 的一部分。要使用此方法,您必須首先在客戶端上創(chuàng)建 SOAPClient 對象。然后,使用 WSDL 文件的名稱、服務(wù)名稱和端口名稱作為參數(shù)來調(diào)用 mssoapinit 方法?,F(xiàn)在,客戶端可以針對所請求的服務(wù)或端口來調(diào)用 WSDL 文件中定義的任何操作。
ClientProperty 屬性設(shè)置和檢索特定于 SOAPClient 對象的屬性。
方法定義
[propget] HRESULT ClientProperty( [in] BSTR PropertyName, [out, retval] VARIANT* pPropertyValue);[propput] HRESULT ClientProperty( [in] BSTR PropertyName, [in] VARIANT pPropertyValue);
參數(shù)
PropertyName PropertyName 是要設(shè)置或檢索的屬性的名稱。有關(guān)屬性列表,請參閱下面的備注部分。以下屬性受支持(屬性名稱區(qū)分大小寫):
屬性名稱 | 說明 |
ServerHTTPRequest | True/False 值表示是否使用“服務(wù)器安全的”XML 組件來加載 Web 服務(wù)描述語言 (WSDL) 和 Web 服務(wù)元語言 (WSML) 文件。在 Active Server Pages (ASP) 應(yīng)用程序或 ISAPI DLL 使用 SOAPClient 對象時,請設(shè)置為 True。 若 ServerHTTPRequest 設(shè)置為 true,則必須使用 WinHTTP 代理配置實用程序來配置 WinHTTP。即使不使用代理服務(wù)器,也必須這樣做。下載實用程序并遵循下載資料的 ReadMe.txt 文件中提供的使用說明來操作。 |
ConnectorProgID | 指定實現(xiàn) ISOAPConnector 接口的類的 ProgID。將請求發(fā)送給服務(wù)時將創(chuàng)建和使用該類的對象。當(dāng)設(shè)置為空字符串(默認(rèn)值)時,SOAPClient 將使用 SOAPConnectorFactory 對象來創(chuàng)建 WSDL 中指定的傳輸協(xié)議的連接器。 |
pPropertyValue
pPropertyValue 是該屬性的值。
Visual Basic 語法
Property ClientProperty(PropertyName As String) As Variant
Visual Basic 示例
Dim Client As New SOAPClientClient.ClientProperty("ServerHTTPRequest") = True
設(shè)置和檢索特定于傳輸協(xié)議連接器(由 SOAPClient 對象使用)的屬性。
方法定義
[propget] HRESULT ConnectorProperty ( [in] BSTR PropertyName, [out, retval] VARIANT* pPropertyValue);[propput] HRESULT ConnectorProperty ( [in] BSTR PropertyName, [in] VARIANT pPropertyValue);
參數(shù)
PropertyName
PropertyName 是要設(shè)置或檢索的屬性的名稱。支持哪些屬性取決于所使用的連接器。由 Web 服務(wù)描述語言 (WSDL) 文件中的 傳輸屬性指定的協(xié)議決定要使用的連接器。
pPropertyValue
pPropertyValue 是該屬性的值。
Visual Basic 語法
Property ConnectorProperty(PropertyName As String)
Visual Basic 示例
Dim Client As New SOAPClientClient.mssoapinit WSDLFile, Service, PortClient.ConnectorProperty("ProxyUser") = UserClient.ConnectorProperty("ProxyPassword") = Password
屬性 | 說明 |
AuthPassword | 用于終結(jié)點身份驗證的密碼。 |
AuthUser | 用于終結(jié)點身份驗證的用戶名。 |
EndPointURL | 終結(jié)點 URL。 |
ProxyPassword | 用于代理身份驗證的密碼。 |
ProxyPort | 要使用的代理服務(wù)器端口。 |
ProxyServer | 代理服務(wù)器的 IP 地址或主機名。 |
ProxyUser | 用于代理身份驗證的用戶名 |
SOAPAction | SOAPAction HTTP 標(biāo)頭中使用的值。 |
SSLClientCertificateName | 識別客戶端證書以用于安全套接字層 (SSL) 協(xié)議的字符串(如果有)。語法為: [CURRENT_USER | LOCAL_MACHINE\[store-name\]]cert-name 默認(rèn)為 CURRENT_USER\MY(Microsoft Internet Explorer 所使用的同一存儲區(qū))。 |
Timeout | HttpConnector 的超時。該超時的單位是毫秒。 |
UseSSL | 指定是否使用 SSL 的布爾值(true 或 false)。 |
detail 屬性是只讀屬性。它提供簡單對象訪問協(xié)議 (SOAP) 消息中 <Fault>元素的 <detail>元素的值。
方法定義
[propget] HRESULT detail( [out, retval] BSTR* bstrDetail);
參數(shù)
bstrDetail
bstrDetail 是錯誤的詳細(xì)信息。
Visual Basic 語法
Property detail As String
為對該客戶端實例的下一個調(diào)用設(shè)置標(biāo)頭處理程序。
方法定義
HRESULT HeaderHandler([in] IDispatch* rhs);
參數(shù)
rhs
rhs 是對實現(xiàn) IHeaderHandler 的 COM 類接口的引用。
Visual Basic 語法
Property HeaderHandler As Object
Visual Basic 示例
Set sc = WScript.CreateObject("MSSOAP.SOAPClient")sc.mssoapinit "http://localhost/DocSample7/DocSample7.wsdl"sc.HeaderHandler = WScript.CreateObject("SessionInfoClient.clientHeaderHandler")Sc.SomeMethod "param1", "param2"
faultactor 屬性是只讀屬性,它提供生成該錯誤的統(tǒng)一資源標(biāo)識符 (URI)。
方法定義
[propget] HRESULT faultactor( [out, retval] BSTR* bstrActor);
參數(shù)
bstrActor
bstrActor 是生成該錯誤的 URI。
Visual Basic 語法
Property faultactor As String
Visual Basic 示例
wscript.echo soapclient.faultactor
faultcode 屬性是只讀屬性。它提供簡單對象訪問協(xié)議 (SOAP) 消息中<Fault> 元素的 <faultcode> 元素的值。
方法定義
[propget] HRESULT faultcode( [out, retval] BSTR* bstrFaultcode);
參數(shù)
bstrFaultcode
bstrFaultcode 是 <faultcode>元素的值。
Visual Basic 語法
Property faultcode As String
Visual Basic 示例
wscript.echo soapclient.faultcode
該 faultstring 屬性是只讀屬性。它提供簡單對象訪問協(xié)議 (SOAP) 消息中 <Fault>元素的 <faultstring>元素的值。
方法定義
[propget] HRESULT faultstring( [out, retval] BSTR* bstrFaultstring);
參數(shù)
bstrFaultstring
bstrFaultstring 是 <faultstring> 元素的值。
Visual Basic 語法
Property faultstring As String
Visual Basic 示例
wscript.echo soapclient.faultstring