Я пытаюсь отправить файлы с мылом. но как-то не получилось. Помогите мне, пожалуйста, дайте мне коды ниже и ошибку, которую я получил.
public void SendTest () {
try {
String filePath = "C:/test/fb344a10-713a-4e45-8810-6a82237947af.zip";
String host = "https://test.efatura.gov.tr/earsiv/services/EArsivWsPort?wsdl";
SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
SOAPConnection connection = soapConnectionFactory.createConnection();
java.net.URL endpoint = new URL(host);
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage message = messageFactory.createMessage();
SOAPPart soapPart = message.getSOAPPart();
SOAPEnvelope soapEnvelope = soapPart.getEnvelope();
soapEnvelope.addNamespaceDeclaration("EArsivWsService", "http://earsiv.vedop3.ggm.gov.org/");
SOAPHeader header = message.getSOAPHeader();
SOAPBody body = message.getSOAPBody();
// QName qNameMethod=new QName("","sendDocumentFile","tns");
// SOAPBodyElement bodyElement = (SOAPBodyElement)
// body.addChildElement(qNameMethod);
SOAPFactory soapFactory = SOAPFactory.newInstance();
Name bodyName = soapFactory.createName("http://earsiv.vedop3.ggm.gov.org/", "tns", "sendDocumentFile");
body.addChildElement(new QName("name","fb344a10-713a-4e45-8810-6a82237947af.zip"));
URL url = new File(filePath).toURI().toURL();
DataHandler dataHandler = new DataHandler(url);
AttachmentPart attachment = message.createAttachmentPart(dataHandler);
// attachment.setContentId("");
message.addAttachmentPart(attachment);
message.saveChanges();
SOAPMessage response = connection.call(message, endpoint);
ByteArrayOutputStream bOutput = new ByteArrayOutputStream(8192);
response.writeTo(bOutput);
String strResponse = bOutput.toString();// TODO use encoding for turkish
System.out.println(strResponse);
} catch (SOAPException | IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Ошибка ответа:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<soap:Fault>
<faultcode xmlns:ns1="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">ns1:InvalidSecurity</faultcode>
<faultstring>An error was discovered processing the <wsse:Security> header</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>