Пытаюсь прикрутить к SOAP сообщению несколько файлов. Но при попытке отправить это сообщение выдается ошибка : 11.10.2006 9:54:08 com.sun.xml.messaging.saaj.soap.MessageImpl saveChanges SEVERE: SAAJ0540: Error during saving a multipart message
| Код | SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance(); SOAPConnection connection = soapConnectionFactory.createConnection(); MessageFactory factory = MessageFactory.newInstance(); SOAPMessage message = factory.createMessage(); int lng = files.length; for (int i = 0; i < lng; i++) { URL url = new URL("file://localhost/" + files[i]); //выбор файла DataHandler dataHandler = new DataHandler(url); AttachmentPart attachment = message.createAttachmentPart(dataHandler); attachment.setContentId("attached_file" + i);
message.addAttachmentPart(attachment); } URL targetURL = new URL("http://127.0.0.1:8060/proj/servlet1"); SOAPMessage response = connection.call(message, targetURL); System.out.println(response.toString()); //проверка, что пришло что-нибудь connection.close();
|
Сообщение принимает сервлет, который не обрабатывает сообщение, а только отсылает ответ о том что к нему все-таки обращались:
| Код | public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType(CONTENT_TYPE); PrintWriter out = response.getWriter(); out.println("<html>"); out.println("<head><title>Servlet1</title></head>"); out.println("<body>"); out.println("<p>The servlet has received a GET. This is the reply.</p>"); out.println("<p>Update servlet.</p>"); out.println("</body></html>"); out.close(); }
|
И почему все-таки выскакивает ошибка?
Заранее спасибо!
|