如何解决“缺少起始边界,或者边界不在新行上开始”

时间:2019-08-02 18:31:11

标签: java soap mime-types soap-client

在正文和图像中以xml为附件执行Soap调用时如何设置边界,并且应用程序接受多部分/相关内容

URL myUrl = myFile.toURI().toURL();


      MimeHeaders he = new MimeHeaders();
      he.addHeader("Content-Type",
                "multipart/related; " +
                        "boundary=MIMEBoundaryurn_uuid_E3F7CE4554928DA89B1231365678616; " +
                        "type=\"text/xml\"; " +
                        "start=\"<0.urn:uuid:E3F7CE4554928DA89B1231365678617@apache.org>\"");

         he.setHeader("Encoding", "UTF-8");

    InputStream xml = new ByteArrayInputStream(ele1.getBytes());
    SOAPMessage request = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL)
            .createMessage(he, xml);

    DataHandler handler = new DataHandler(myUrl);
    AttachmentPart attachPart = request.createAttachmentPart(handler);
    attachPart.setContentId(fileid);
    attachPart.setContentType("multipart/related");
    request.addAttachmentPart(attachPart); 
    request.saveChanges();
    System.out.println(request.countAttachments() +"   ----count of attachments");



        SOAPConnectionFactory scf = SOAPConnectionFactory.newInstance();
        SOAPConnection conn = scf.createConnection();

        disableCertificateValidation();

        SOAPConnection connection = SOAPConnectionFactory.newInstance().createConnection();
        SOAPMessage returnMessage = connection.call(request, eAppURL);
        System.out.println("Client - Response from server is : " + returnMessage.getSOAPPart().getEnvelope().toString());



}           

使用上面的代码,我收到以下错误消息

  CAUSE:

  java.lang.Exception: Missing Start Boundary, or boundary does not start on a new line

如何解决边界错误?

0 个答案:

没有答案