使用 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>hQE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x0gMB9CWfdymOFK9Mf</ucm:Contents>
                    </ucm:File>
                </ucm:Document>
            </ucm:Service>
        </ucm:GenericRequest>
    </soapenv:Body>
</soapenv:Envelope>

但是,由于 HCM 数据加载程序文件通常很大,因此建议使用消息传输优化机制 (Message Transmission Optimization Mechanism,MTOM) 和 XML 二进制优化打包 (XOP) 来调用 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 Content 文档传输实用程序上载工具

您可以通过编程方式使用 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 发行版,以确保应用了最新的 bug 修复和安全更新。

关于上载工具参数

调用 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(默认值)。

还可以传递一些用于调试或无提示调用用例的可选参数:

  • version :打印 UploadTool 修订版和版本。

  • ping :执行 PING_SERVER 测试以验证连接 URL 和身份证明。

  • 详细:配置详细输出以记录完整请求和响应数据绑定器。

  • quiet :配置最少的日志输出。

  • silent :禁用日志消息。

  • 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. 在函数主体中,创建一个 List 对象,该对象将包含 urlusernamepassword 以及核心参数(如 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 服务器。