我正在將資料從我們的 Web 應用程式發送到 Oracle UCM。我面臨著轉換存盤在檔案中的 SOAP 回應的挑戰。稍后我從檔案中讀取該回應并轉換為 XML 以獲取回應代碼。下面是代碼:
$response | Out-File $out_path
$Status=($response.Envelope.Body.uploadFileToUcmResponse.return)
Write-Host $Status
$soap_object= get-content -path $out_path
[xml] $xml=$soap_object[5..6]
$result=$xml.Envelope.Body.uploadFileToUcmResponse.result."#text"
$result
我在這一行遇到錯誤
**[xml] $xml=$soap_object[5..6]**
無法從物件轉換為 xml 檔案。我花了很多時間來解決這個問題。但這是徒勞的。如果你知道答案,請回復我。
以下是我的 SOAP 回應。
--=_Part_920_1255941941.1652372974539
Content-Type: application/xop xml;charset=utf-8;type="text/xml"
Content-Transfer-Encoding: 8bit
Content-ID: <83415eb1-1a64-4eeb-be91-e4ad0b837350>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing"><env:Header><wsa:Action>http://xmlns.oracle.com/apps/financials/commonModules/shared/financialUtilService/FinancialUtilService/uploadFileToUcmResponse</wsa:Action><wsa:MessageID>urn:uuid:92433bfb-3f44-4a99-8513-8c2a274818fa</wsa:MessageID></env:Header><env:Body><ns0:uploadFileToUcmResponse xmlns:ns0="http://xmlns.oracle.com/apps/financials/commonModules/shared/financialUtilService/types/"><result xmlns="http://xmlns.oracle.com/apps/financials/commonModules/shared/financialUtilService/types/">10211536</result></ns0:uploadFileToUcmResponse></env:Body></env:Envelope>
------=_Part_920_1255941941.1652372974539--
提前致謝。
uj5u.com熱心網友回復:
更改[xml] $xml=$soap_object[5..6]
為[xml] $xml=$soap_object[5]
,因為第 6 行 (index 5
) 僅包含您要決議的 XML 文本。
但是,除非您需要檔案中的標頭欄位,否則請考慮使用$response.Content | Out-File $out_path
以僅保存回應的內容,即僅保存 XML,這樣您就可以簡化為[xml] $xml=$soap_object
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/474169.html