MongoDB에 문제가 있습니다. Java SOAP 웹 서비스가 있고 앞면이 Angular/Bootstrap/Jquery이고 내 mongo 데이터베이스에 파일을 저장해야합니다. 3 일 동안이 작업을 시도하고 있는데 jquery/js가 SOAP 서비스를 호출하는 예제가 필요하거나 js를 직접 호출해야합니다. <input type="file" id="file"/>
과 함께 파일을 수신하고 있습니다. 도움 주셔서 감사합니다. 내 파일 형식이 mongo 데이터베이스에 저장해야하는 것보다 json 및 이미지가있는 tgz입니다.파일을 MongoDB에 저장하십시오.
function uploadCard() {
var fileList = new Array();
fileList = document.getElementById("file").files;
var fr = new FileReader();
if (FileReader && fileList && fileList.length) {
fr.readAsArrayBuffer(fileList[0]);
imageData = fr.result;
}
jQuery.support.cors = true;
var wsUrl = "http://" + window.location.hostname + ":7004/CardServiceImpl/CardService?WSDL";
var soapRequest = crateCardSoapRequest(document.getElementById("file").files[0]);
$.ajax({
crossDomain: true,
type: "POST",
url: wsUrl,
contentType: "text/xml",
dataType: "xml",
data: soapRequest,
success: processSuccess,
error: processError
});
}
function crateCardSoapRequest(input) {
var req = "<soap:Envelope xmlns:soap=" + '"' + "http://schemas.xmlsoap.org/soap/envelope/" + '"' + ">" +
"<soap:Body>" +
"<ns1:uploadCard xmlns:ns1=" + '"' + " http://card.ejb.card_editor.com.br/" + '"' + ">" +
"<arg0>" +
"<cardBean>"+
"<description>StringValue</description>" +
"<id>23</id>" +
"<name>StringValue</name>" +
"<file>" + input + "</file>" +
"<template>" + "</template>" +
"</cardBean>" +
"<nickNameUser>lucas_santos</nickNameUser>" +
"</arg0>" +
"</ns1:uploadCard>" +
"</soap:Body>" +
"</soap:Envelope>";
}
내 비누 매개 변수는
당신은 3 일 동안 노력했다고 말합니다. 그 시간 동안 어떤 접근법을 시도 했습니까? 어떤 문제가 발생 했습니까? –
Angular 또는 jQuery를 사용하고 있습니까? 어쨌든 데이터베이스는 파일을 저장하지 않습니다. URL을 파일에 저장합니다. –
나는 비누 매개 변수에 파일을 전달하려고 시도하고 아약스 요청이 내 메서드를 인식하지 못했습니다. 바이너리 배열이나 문자열로 변환해야한다고 생각하지만이 작업을 수행하지 못했습니다. –