使用 JAX-RPC 客户端从 JAX-WS WebService 获取附件

发布于 2024-10-08 07:56:30 字数 3651 浏览 1 评论 0原文

当我们从 JAX-RPC 迁移到 JAX-WS 时,我尝试调用使用 JAX-W/JAXB 的 WebService。客户端本身仍然使用JAX-RPC。 WSDL 文件保持不变。

只要没有附件,这种方法就可以正常工作。有了附件就不行了。客户说,没有。虽然它们可以在 SOAP-Message 中看到。

据我了解这个问题,JAX-WS确实使用MTOM将二进制数据放入消息中,而JAX-RPC使用MIME。

有可能以某种方式让它发挥作用吗?

JAX-RPC 消息如下所示:

HTTP/1.1 200 OK
Date: Tue, 21 Dec 2010 15:24:10 GMT
Transfer-Encoding: chunked
Content-Type: multipart/related;boundary="----=_Part_6_5206227.1292945050584";type="text/xml";start="<soapPart>"
SOAPAction: "http://XXX"
X-Powered-By: Servlet/2.5 JSP/2.1

014a
------=_Part_6_5206227.1292945050584
Content-Type: text/xml; charset=utf-8
Content-Transfer-Encoding: 8bit
Content-ID: <soapPart>

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Header/><env:Body><operationWithAttachments href="cid:operationWithAttachments"/></env:Body></env:Envelope>
0522

------=_Part_6_5206227.1292945050584
Content-Type: multipart/mixed; 
    boundary="----=_Part_5_12763436.1292945050570"
Content-ID: <operationWithAttachments>

------=_Part_5_12763436.1292945050570
Content-Type: application/pdf; name=HelloWorld.pdf
Content-Disposition: attachment; filename=HelloWorld.pdf

%PDF-1.4
%öäüß
1 0 obj
<<
/Type /Catalog
/Version /1.4
/Pages 2 0 R
>>
endobj
2 0 obj
<<
...

这里是新的 JAX-WS 消息:(

HTTP/1.1 200 OK
Date: Tue, 21 Dec 2010 15:23:02 GMT
Transfer-Encoding: chunked
Content-Type: multipart/related;start="<rootpart*[email protected]>";type="application/xop+xml";boundary="uuid:07499eba-7835-4fe0-bb07-a04801504fb5";start-info="text/xml"
X-Powered-By: Servlet/2.5 JSP/2.1

02ba
--uuid:07499eba-7835-4fe0-bb07-a04801504fb5
Content-Id: <rootpart*[email protected]>
Content-Type: application/xop+xml;charset=utf-8;type="text/xml"
Content-Transfer-Encoding: binary

<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns6:operationWithAttachments xmlns:ns6="XX" xmlns:ns5="XX" xmlns:ns4="XX" xmlns:ns3="XX" xmlns:ns2="XX" xmlns="XX">
00ba
<Include xmlns="http://www.w3.org/2004/08/xop/include" href="cid:[email protected]"/></ns6:operationWithAttachments></S:Body></S:Envelope>
0562

--uuid:07499eba-7835-4fe0-bb07-a04801504fb5
Content-Id: <[email protected]>
Content-Type: multipart/mixed; boundary="----=_Part_4_6279014.1292944982388"
Content-Transfer-Encoding: binary

------=_Part_4_6279014.1292944982388
Content-Type: application/pdf; name=HelloWorld.pdf
Content-Disposition: attachment; filename=HelloWorld.pdf

%PDF-1.4
%öäüß
1 0 obj
<<
/Type /Catalog
/Version /1.4
/Pages 2 0 R
>>
endobj
2 0 obj
<<
...

我自己删除了命名空间,所以这不是问题)

我们的想法是让它们相同。

有人这样做过吗?

非常感谢您的帮助

As we migrate from JAX-RPC to JAX-WS I'm trying to Call a WebService, which uses JAX-W/JAXB. The client itself is still using JAX-RPC. The WSDL File is kept the same.

This works fine, as long, as there are no attachments. With attachments, it doesn't work. The client says, there are none. Although they can be seen in the SOAP-Message.

As far as I understood the problem, JAX-WS does use MTOM to put the binary data into the message, while JAX-RPC uses MIME.

Is it possible to somehow get this to work?

Here's how the JAX-RPC message looks:

HTTP/1.1 200 OK
Date: Tue, 21 Dec 2010 15:24:10 GMT
Transfer-Encoding: chunked
Content-Type: multipart/related;boundary="----=_Part_6_5206227.1292945050584";type="text/xml";start="<soapPart>"
SOAPAction: "http://XXX"
X-Powered-By: Servlet/2.5 JSP/2.1

014a
------=_Part_6_5206227.1292945050584
Content-Type: text/xml; charset=utf-8
Content-Transfer-Encoding: 8bit
Content-ID: <soapPart>

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Header/><env:Body><operationWithAttachments href="cid:operationWithAttachments"/></env:Body></env:Envelope>
0522

------=_Part_6_5206227.1292945050584
Content-Type: multipart/mixed; 
    boundary="----=_Part_5_12763436.1292945050570"
Content-ID: <operationWithAttachments>

------=_Part_5_12763436.1292945050570
Content-Type: application/pdf; name=HelloWorld.pdf
Content-Disposition: attachment; filename=HelloWorld.pdf

%PDF-1.4
%öäüß
1 0 obj
<<
/Type /Catalog
/Version /1.4
/Pages 2 0 R
>>
endobj
2 0 obj
<<
...

And here the new JAX-WS message:

HTTP/1.1 200 OK
Date: Tue, 21 Dec 2010 15:23:02 GMT
Transfer-Encoding: chunked
Content-Type: multipart/related;start="<rootpart*[email protected]>";type="application/xop+xml";boundary="uuid:07499eba-7835-4fe0-bb07-a04801504fb5";start-info="text/xml"
X-Powered-By: Servlet/2.5 JSP/2.1

02ba
--uuid:07499eba-7835-4fe0-bb07-a04801504fb5
Content-Id: <rootpart*[email protected]>
Content-Type: application/xop+xml;charset=utf-8;type="text/xml"
Content-Transfer-Encoding: binary

<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns6:operationWithAttachments xmlns:ns6="XX" xmlns:ns5="XX" xmlns:ns4="XX" xmlns:ns3="XX" xmlns:ns2="XX" xmlns="XX">
00ba
<Include xmlns="http://www.w3.org/2004/08/xop/include" href="cid:[email protected]"/></ns6:operationWithAttachments></S:Body></S:Envelope>
0562

--uuid:07499eba-7835-4fe0-bb07-a04801504fb5
Content-Id: <[email protected]>
Content-Type: multipart/mixed; boundary="----=_Part_4_6279014.1292944982388"
Content-Transfer-Encoding: binary

------=_Part_4_6279014.1292944982388
Content-Type: application/pdf; name=HelloWorld.pdf
Content-Disposition: attachment; filename=HelloWorld.pdf

%PDF-1.4
%öäüß
1 0 obj
<<
/Type /Catalog
/Version /1.4
/Pages 2 0 R
>>
endobj
2 0 obj
<<
...

(i removed the namespaces myself, so that is not the problem)

The idea is to get them to be the same.

Did anyone ever do that?

Thanks a lot for your help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

大姐,你呐 2024-10-15 07:56:30

嗯,据我所知你不能。 JAXRPC 使用 Soap With Attachments,JAXWS 使用更现代的 MTOM。它们略有不同并且不兼容。您可以禁用 MTOM,但随后您必须找到另一种方式来传输附件(另一种服务)。

Well AFAIK you can't. JAXRPC uses Soap With Attachments, JAXWS the more modern MTOM. They are slightly different and not compatible. You can disable MTOM, but then you have to find another way to stream attachments (another service).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文