相关疑难解决方法(0)

具有MTOM附件的Spring-WS Web服务 - Hello world测试

我正在尝试创建一个简单的Spring Web服务,在调用时返回文件附件作为SOAP响应的一部分.Enpoint类如下所示:

最后是终点

@PayloadRoot(namespace="http://ws.mypackage.com", localPart="downloadMessageRequest")
    @ResponsePayload
    public JAXBElement<DownloadResponseType> invoke(@RequestPayload DownloadMessageRequest req) throws Exception  {

        DownloadResponseType response = new DownloadResponseType();
        DownloadResponseType.PayLoad payload = new DownloadResponseType.PayLoad();          

        javax.activation.DataHandler dataHandler = new javax.activation.DataHandler(new FileDataSource("c:\\temp\\maven-feather.png"));
        payload.setMessagePayLoad(dataHandler);
        response.setPayLoad(payload);

        return objectFactory.createDownloadMessageResponse(response);

    }
Run Code Online (Sandbox Code Playgroud)

我希望响应将文件包含为类似于以下响应的附件:

Content-Type: multipart/related; boundary=MIMEBoundary4A7AE55984E7438034;
                         type="application/xop+xml"; start="<0.09BC7F4BE2E4D3EF1B@apache.org>";
                         start-info="text/xml; charset=utf-8"

--MIMEBoundary4A7AE55984E7438034
content-type: application/xop+xml; charset=utf-8; type="application/soap+xml;"
content-transfer-encoding: binary
content-id: <0.09BC7F4BE2E4D3EF1B@apache.org>

<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="...."....>
  ........
         <xop:Include href="cid:1.A91D6D2E3D7AC4D580@apache.org" 
                        xmlns:xop="http://www.w3.org/2004/08/xop/include">
         </xop:Include>
  ........

</soapenv:Envelope>
--MIMEBoundary4A7AE55984E7438034
content-type: application/octet-stream
content-transfer-encoding: binary
content-id: <1.A91D6D2E3D7AC4D580@apache.org>

Binary Data.....
--MIMEBoundary4A7AE55984E7438034--
Run Code Online (Sandbox Code Playgroud)

我试图遵循spring-ws示例中的文档和示例代码,由于某种原因,我得到的输出总是这样(即base64数据不是附件.

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1 …
Run Code Online (Sandbox Code Playgroud)

java spring soap jaxb mime-types

8
推荐指数
1
解决办法
1万
查看次数

标签 统计

java ×1

jaxb ×1

mime-types ×1

soap ×1

spring ×1