Apache camel Camel中的ServiceNow附件

Apache camel Camel中的ServiceNow附件,apache-camel,jbossfuse,servicenow,Apache Camel,Jbossfuse,Servicenow,如何从camel connector下载或上传附件到servicenow。该项目使用maven中的camel servicenow(v2.21.0.fuse-000077-redhat-1)进行设置。创建、检索和更新票证工作正常,但无法使用附件资源下载任何附件。下载: url = "https4://" + instance + ".service-now.com/api/now/v1/attachment?sysparm_query=" +

如何从camel connector下载或上传附件到servicenow。该项目使用maven中的camel servicenow(v2.21.0.fuse-000077-redhat-1)进行设置。创建、检索和更新票证工作正常,但无法使用附件资源下载任何附件。

下载:

url = "https4://" 
        +  instance
        + ".service-now.com/api/now/v1/attachment?sysparm_query="
        + "table_name=" 
        + table 
        + "%5Etable_sys_id=" 
        + sysId
        + "&authenticationPreemptive=true&authUsername=" 
        + username 
        + "&authPassword="
        + password
        + "&authMethod=Basic";
在路线定义中:

from("direct:servicenowAttachmentDownload").setHeader(Exchange.HTTP_METHOD, constant("GET")).recipientList().simple("${header.url}")
from("direct:servicenowAttachmentUpload").process(new Processor() {
        public void process(Exchange exchange) throws Exception {
            MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder.create();
            multipartEntityBuilder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
            multipartEntityBuilder.setContentType(ContentType.MULTIPART_FORM_DATA);

            String filename = (String) exchange.getIn().getHeader(Exchange.FILE_NAME);

            String filePath = (String) exchange.getIn().getHeader("filePath");
            String attachmentName = (String) exchange.getIn().getHeader("attachmentName");

            File file = new File(filePath);
            multipartEntityBuilder.addPart("upload",
                    new FileBody(file, ContentType.MULTIPART_FORM_DATA, attachmentName));
            exchange.getIn().setBody(multipartEntityBuilder.build());
        }
    }).removeHeaders("CamelHttp*").setHeader(Exchange.HTTP_METHOD, constant("POST")).recipientList()
            .simple("${header.url}")
上传:

url = "https4://"
        + instance
        + ".service-now.com/api/now/attachment/file?table_name="
        + table
        + "&table_sys_id="
        + sysId
        + "&file_name="
        + attachmentName
        + "&authenticationPreemptive=true&authUsername="
        + username
        + "&authPassword="
        + password
        + "&authMethod=Basic";
在路线定义中:

from("direct:servicenowAttachmentDownload").setHeader(Exchange.HTTP_METHOD, constant("GET")).recipientList().simple("${header.url}")
from("direct:servicenowAttachmentUpload").process(new Processor() {
        public void process(Exchange exchange) throws Exception {
            MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder.create();
            multipartEntityBuilder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
            multipartEntityBuilder.setContentType(ContentType.MULTIPART_FORM_DATA);

            String filename = (String) exchange.getIn().getHeader(Exchange.FILE_NAME);

            String filePath = (String) exchange.getIn().getHeader("filePath");
            String attachmentName = (String) exchange.getIn().getHeader("attachmentName");

            File file = new File(filePath);
            multipartEntityBuilder.addPart("upload",
                    new FileBody(file, ContentType.MULTIPART_FORM_DATA, attachmentName));
            exchange.getIn().setBody(multipartEntityBuilder.build());
        }
    }).removeHeaders("CamelHttp*").setHeader(Exchange.HTTP_METHOD, constant("POST")).recipientList()
            .simple("${header.url}")

你能用一个例子来丰富你的问题吗?我正在使用jboss的servicenow连接器,需要上传和下载附件。这个测试可能会有帮助,但如果能有一个你正在做的例子,那就太好了