简体   繁体   中英

Get attachments from a JAX-WS WebService with a JAX-RPC Client

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*07499eba-7835-4fe0-bb07-a04801504fb5@example.jaxws.sun.com>";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*07499eba-7835-4fe0-bb07-a04801504fb5@example.jaxws.sun.com>
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:9832a057-f692-4f48-ac7d-4dbd7ce76a74@example.jaxws.sun.com"/></ns6:operationWithAttachments></S:Body></S:Envelope>
0562

--uuid:07499eba-7835-4fe0-bb07-a04801504fb5
Content-Id: <9832a057-f692-4f48-ac7d-4dbd7ce76a74@example.jaxws.sun.com>
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

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM