使用 WebCenter 內容一般 SOAP Web 服務上傳 HCM 資料載入器 ZIP 檔案

Oracle WebCenter Content 伺服器會顯示您可以用來上傳檔案的 SOAP Web 服務介面 (GenericSoapPort)。

使用內嵌內容呼叫 WebCenter 內容一般 SOAP Web 服務

您可以傳送內嵌內容以及 GenericSoapPort Web 服務呼叫。

從下列位置取得 Web 服務的 WSDL 檔案:

https://{host}/idcws/GenericSoapPort?wsdl

主機是您的 Oracle Fusion Cloud Applications URL。

要求的主體包含下列參數:

參數 意義 HCM 資料載入器的註解
IdcService

要呼叫的服務。

用於上傳檔案的 CHECKIN_UNIVERSAL

dDocName

內容項目的內容 ID。

傳遞至 HcmDataLoader 的值

dDocAuthor

內容項目作者 (提供者)。

 
dDocTitle

內容項目標題。

檔案出現在匯入 / 匯出 UI 中的標題

dDocType

內容項目類型。

文件

dSecurityGroup

安全群組,例如 PublicSecure

FAFusionImportExport

dDocAccount

內容項目的帳戶。只有在帳戶啟用時,才需指定此值。

hcm$/dataloader$/import$

primaryFile

從伺服器見到的檔案位置絕對路徑。

 

dDocName 值是回應的一部分,代表要用於進一步「HCM 資料載入器」處理的內容 ID。

您可以在傳送要求時選擇性使用信封,例如:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ucm="http://www.oracle.com/UCM" xmlns:wsse="http://schemas.xmlsoap.org/ws/2003/06/secext">
    <soapenv:Header />
    <soapenv:Body>
        <ucm:GenericRequest webKey="cs">
            <ucm:Service IdcService="CHECKIN_UNIVERSAL">
                <ucm:User />
                <ucm:Document>
                    <ucm:Field name="dDocTitle">Department Load File</ucm:Field>
                    <ucm:Field name="dDocType">Document</ucm:Field>
                    <ucm:Field name="dDocAuthor">YOUR_HCM_USER_NAME</ucm:Field>
                    <ucm:Field name="dSecurityGroup">FAFusionImportExport</ucm:Field>
                    <ucm:Field name="dDocAccount">hcm$/dataloader$/import$</ucm:Field>
                    <ucm:Field name="primaryFile">YourZipFile.zip</ucm:Field>
                    <ucm:File href="YourZipFile.zip" name="primaryFile">
                        <ucm:Contents>hQEMA+8YN513c6VEAQf9EstURU0V2erP9hNIP34P6cvwdi2G8hmtTY4dj+jpjSBiBwF28SzOGO5Q T/S6LDM1lAd9fHDFO4CFTEUkiMiAfa4jCpkh2kjvrV05GYiy9rlYGbgjRa38t0Boj0G8dkZia4kw lD5zloegTb4k9dp2ZXtAkJjVPTlmaVs7wPjqHJOk1Dtj+zUL/Dvq/X+rcmBtnvZ6+gX1r/PSBYsI ANiUK36pUac916p1wrYbePtmLs9rLB8dZTIdKE3pbi3aIKECnqnfXN3Rx8BT3afI2kWA9xEsEBwL XSgD4EUlYY2lWKM0wQrSCIfz1jit4zK+vs1Jp3zP3kSFfMH9h5b70ATYCNLpAXTmolmJxhvg9nPN RbgWGM0jWuVE7tXEVL66s2XJuV6HCyJ+3QDTSS/hEzUorpbaH7gOPdd2d9uIJayseWmgkCLhpgNM Ml4dGGDEL7ISZNKbu39MWvptFC5wrFX/VyB0E3kZF3xJ9dHz5UzVN3hiji6/ZLnUKRI+mpY41gEQ BdLm/WehWRLkF9yWhdkKOK1imBa+oLCeZg2YcCPNVqMaf42atoix9kSR+PCdB46SGnyQ2kvx0z9V t+4A/70psaMEOgPmUciQ/CNoC3vPdDs/G+p8Run/9MHoZoW5o2KpGC1M4j593BulKnfE7JZdYopG b1MS9Vrd6e4Oj3ZD7ISyrf8gEsEhvRu4se0CnAA8W2Fj2u88TOBn/rX+9NMffGwwO040a00N4upV 70xY0I0mvMzPKh4u4kHHQLaV7+fChTHIRCXFjvN2ziyGdSCYxiZ9tfhms39jPp2LxJKPnsV5GgC8 XSqpzxipYjbZjpqvKAu0k9VhIF4vHlGjTbzZuhz/CETs5Aj2LXvJksIBpDq6whUK7/LKR3hmfKXi e4xng6B4TwSEvhvRDY0+V2np1RMxzlqW0W3XNpKYqkS2kjO7vQM65CBAqeQjYAW9p1tE1k1S5G2N 1whW46eYIQvN68SzkCQIsafzoAtgKKYClEwJuxGE004i6AluJ0keWx+ZzXohyIxx8eTiw7vp5PIS tm2WTriBJ/x0gMB9CWfdymOFK9Mf</ucm:Contents>
                    </ucm:File>
                </ucm:Document>
            </ucm:Service>
        </ucm:GenericRequest>
    </soapenv:Body>
</soapenv:Envelope>

不過,由於 HCM 資料載入器檔案通常很大,因此建議您使用含有 XML 二進位最佳化封裝 (XOP) 的訊息傳輸最佳化機制 (MTOM) 來呼叫 Web 服務。下列要求範例顯示上傳含有 MTOM/XOP 之 HCM 資料載入器 ZIP 檔案的要求有效負載:

POST http://{host}/idcws/GenericSoapPort HTTP/1.1 
Accept-Encoding: gzip,deflate
Content-Type: multipart/related; type="application/xop+xml"; start="<rootpart@example.com>"; start-info="text/xml"; boundary="----=_Part_7_163289738.1476693003095" 
SOAPAction: "urn:GenericSoap/GenericSoapOperation"
Authorization: Basic YOUR_AUTHORIZATION_TOKEN 
MIME-Version: 1.0 
Content-Length: 4030385
Host: {host} User-Agent: Apache-HttpClient/4.1.1 (java 1.5) 
Connection: close 

------=_Part_7_163289738.1476693003095 
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml" 
Content-Transfer-Encoding: 8bit 
Content-ID:<rootpart@example.com>


        <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ucm="http://www.oracle.com/UCM" xmlns:wsse="http://schemas.xmlsoap.org/ws/2003/06/secext">
            <soapenv:Header>
                <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
                    <wsse:UsernameToken wsu:Id="UsernameToken-12345">
                        <wsse:Username>YOUR_HCM_USER_NAME</wsse:Username>
                        <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">YOUR_HCM_ACCOUNT_PASSWORD</wsse:Password>
                        <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">ckNXKVpwBU01PD2ENXg5nw==</wsse:Nonce>
                        <wsu:Created>2018-07-01T08:30:03.094Z</wsu:Created>
                    </wsse:UsernameToken>
                </wsse:Security>
            </soapenv:Header>
            <soapenv:Body>
                <ucm:GenericRequest webKey="cs">
                    <ucm:Service IdcService="CHECKIN_UNIVERSAL">
                        <ucm:User/>
                        <ucm:Document>
                            <ucm:Field name="dDocTitle">Department Load File</ucm:Field>
                            <ucm:Field name="dDocType">Document</ucm:Field>
                            <ucm:Field name="dDocAuthor">HCM_IMPL</ucm:Field>
                            <ucm:Field name="dSecurityGroup">FAFusionImportExport</ucm:Field>
                            <ucm:Field name="dDocAccount">hcm$/dataloader$/import$</ucm:Field>
                            <ucm:Field name="primaryFile">YourZipFile.zip</ucm:Field>
                            <ucm:File href="YourZipFile.zip" name="primaryFile">
                                <ucm:Contents>
                                    <inc:Include href="cid:YourZipFile.zip" xmlns:inc="http://www.w3.org/2004/08/xop/include" />
                                </ucm:Contents>
                            </ucm:File>
                        </ucm:Document>
                    </ucm:Service>
                </ucm:GenericRequest>
            </soapenv:Body>
        </soapenv:Envelope> 
------=_Part_7_163289738.1476693003095 
Content-Type: application/zip; name=YourZipFile.zip 
Content-Transfer-Encoding: binary 
Content-ID:<YourZipFile.zip> 
Content-Disposition: attachment; name="YourZipFile.zip"; filename="YourZipFile.zip"

 <<< binary content ommitted for brevity>>> 
 	
------=_Part_7_163289738.1476693003095--

關於 WebCenter 內容文件移轉公用程式上傳工具

您可以使用 WebCenter Content 文件傳輸公用程式,以程式設計方式將 ZIP 檔案上傳至 WebCenter Content 伺服器。

oracle.ucm.fa_genericclient_11.1.1.jar 中包含的 oracle.ucm.idcws.client.UploadTool 是偏好的一般 SOAP 傳輸公用程式。它需要支援 Oracle JRF Web 服務的程式庫,並使用 HTTPS 上的 JAX/WS 與 WebCenter Content 伺服器通訊。oracle.ucm.idcws.client.UploadTool 可用來將檔案上傳至從本機檔案串流處理的 WebCenter Content

一般 SOAP 傳輸公用程式會透過其 GenericSoapPort Web 服務 (/idcws/GenericSoapPort 存取 WebCenter Content 伺服器,而且要求用戶端指定適當的 UsernameToken 型 Oracle Web Services Manager 安全用戶端原則。

關於 Java Runtime Environment 需求

Oracle Java 6 SE 版本 1.6.0_20 是 Oracle Java Runtime Environment 最早版本,透過 WebCenter Content 文件傳輸公用程式工具順利測試。Oracle 建議您使用最新的 Java 6 SE 或 Java 7 SE 版本,以確保套用最新的錯誤修正和安全更新。

關於上傳工具參數

呼叫 oracle.ucm.idcws.client.UploadTool 時,您必須提供下列參數:

  • urlWebCenter Content 伺服器 GenericSoapPort Web 服務位置,例如:https://<Your_Oracle_WebCenter_Content_Server_URL>/idcws/GenericSoapPort

  • 原則:符合伺服器設定之服務原則 (例如 oracle/wss_username_token_over_ssl_client_policyoracle/wss_username_token_client_policy 原則) 的適當 UsernameToken 型 Oracle Web Services Manager 安全從屬端原則。

  • username :您的 Oracle Cloud HCM 使用者名稱。

  • 密碼:您的 Oracle Cloud HCM 密碼。

  • primaryFile :要上傳的本機檔案完整路徑。

  • dDocAccount :目的地安全帳號。

  • dDocTitle :文件標題。

  • dDocName :如果您要透過提供檔案的 dDocName 值來建立現有檔案的版本,請使用此參數。

  • 結帳:如果您要新增修訂版本,請先執行結帳。此參數的值可以是 truefalse (預設值)。

您也可以傳送一些選擇性參數來進行除錯或無訊息呼叫使用案例:

  • 版本:列印 UploadTool 版次和版本。

  • ping :執行 PING_SERVER 測試以驗證連線 URL 與憑證。

  • 冗長:設定詳細輸出以記錄完整要求和回應資料連結器。

  • quiet :設定最小的日誌輸出。

  • 無訊息:停用日誌訊息。

  • log_file_name :將日誌資訊傳送至與 System.out 不同的外部檔案。

  • log_file_append :設定是否附加日誌與覆寫日誌。

使用一般 SOAP Web 服務以程式設計方式上傳 HCM 資料載入器檔案

上傳 HCM 資料載入器 ZIP 檔案時所使用的程式設計選項之一,是使用 Java 程式設計語言來使用一般 SOAP Web 服務 API。

  1. 在 Java 程式中匯入這些程式庫:
    import java.io.ByteArrayInputStream;
    import java.io.File;
    import java.io.IOException;
    import java.io.InputStream;
    import java.nio.charset.Charset;
    import java.util.ArrayList;
    
    import java.util.List;
    import java.util.Map;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    
    import oracle.stellent.ridc.IdcClientException;
    import oracle.ucm.idcws.client.UploadTool;
    import oracle.ucm.idcws.client.UploadTool.UploadResults;
    import oracle.ucm.idcws.client.bulk.UploadException;
    import oracle.ucm.idcws.client.model.content.CheckinSource;
    import oracle.ucm.idcws.client.model.content.TransferFile;
    import oracle.ucm.idcws.client.model.response.CheckinResponse;
  2. 使用一般 SOAP Web 服務建立將檔案上傳至 WebCenter Content 伺服器的功能:
    public static String uploadFileToUCMwithSOAP(String url, String username, String password, File uploadFile, 
    			String identifier, String dDocName, String dDocTitle, String dSecurityGroup, String dDocAccount, String dDocType) throws Exception {
    		//Insert all the code in the next steps in the body of this function		
    	}
  3. 在函數的主體中,建立一個包含 urlusernamepassword 以及核心引數的 List 物件,像是 OWSM 安全原則。分隔符號分隔),例如:
    		List<String> coreArgs = new ArrayList<String>();
    		coreArgs.add("url=" + url);
    		coreArgs.add("policy=oracle/wss_username_token_over_ssl_client_policy");
    		
    		
    		coreArgs.add("username=" + username);
    		coreArgs.add("password=" + password);
    		coreArgs.add("silent=false"); // minimal log output
    		coreArgs.add("verbose=true"); // verbose log output
    
    		List<String> argsList = new ArrayList<String>();
    		argsList.addAll(coreArgs);
    
    		argsList.add("threads=3");
    		argsList.add("throwOnThreadException=false"); // run() will not throw an exception should a thread error
    		
    		String[] uploadArgs = argsList.toArray(new String[0]);
  4. 建立 UploadTool 物件,並使用 uploadArgs 陣列設定其初始組態。分隔符號分隔),例如:
    		UploadTool uploadTool = new UploadTool();
    
    		// Setup the tool's initial configuration from the supplied arguments.
    		boolean terminateEarly = uploadTool.setup(uploadArgs);
    		if (terminateEarly) {
    			throw new Exception("Error with the UCM UploadTool's initial configuration from the supplied arguments, please check arguments and try again.");
    		}
  5. 新增 Web 服務參數並提出要求:
    	List < CheckinSource > items = new ArrayList < CheckinSource > ();
    	items.add(new LocalFileSource(identifier, dDocName, dDocTitle, dSecurityGroup, dDocAccount, dDocType,
    	    uploadFile.getAbsolutePath()));
    
    	uploadTool.setCheckinItems(items);
    	UploadResults uploadResults = uploadTool.run();
    	if (uploadResults != null) {
    	    Map < Integer, Exception > failedCheckins = uploadResults.getAllFailedCheckinsKeyedByTaskNum();
    	    Map < Integer, UploadException > failedCheckinsDetailed = uploadResults.getFailedCheckinsKeyedByTaskNum();
    	    for (Map.Entry < Integer, Exception > entry: failedCheckins.entrySet()) {
    	        if (failedCheckinsDetailed.containsKey(entry.getKey())) {
    	            UploadException e = failedCheckinsDetailed.get(entry.getKey());
    	            logger.info("Checkin with task number " + e.getTaskNumber() + " and identifier " +
    	                e.getIdentifier() + " failed with message " + e.getMessage());
    	        } else {
    	            logger.info("Checkin with task number " + entry.getKey() + " failed with message " +
    	                entry.getValue().getMessage());
    	        }
    	    }
    
    	    Map < Integer, CheckinResponse > successfulCheckins = uploadResults.getSuccessfulCheckinsKeyedByTaskNum();
    	    for (Map.Entry < Integer, CheckinResponse > entry: successfulCheckins.entrySet()) {
    	        CheckinResponse response = entry.getValue();
    	        logger.info("Checkin with task number " + response.getTaskNumber() + " and identifier " +
    	            response.getIdentifier() + " succeeded. dID=" + response.getDId() + " dName=" + response.getDDocName());
    
    
    
    	    }
    	}
    	return dDocName; // dDocName is whats used by HDL Import	

    當要求執行時,會個別處理每個項目。傳送至日誌記錄器物件的所有失敗項目都會顯示在一側。所有成功項目都會從回應驗證,並記錄在另一端。回應中傳回的內容 ID dDocName,表示檔案已順利上傳至 WebCenter Content 伺服器。