SOAP с вложением - PullRequest
       59

SOAP с вложением

0 голосов
/ 11 марта 2020

Я работаю над приложением, которое использует SAAJ api для формирования SOAP сообщения с вложением. Веб-сервис написан с использованием Java Servlet. В коде веб-сервиса (который является классом сервлета) вложение может быть извлечено методом SOAPMessage.getAttachments (). Но когда тело SOAPMessage отправляется обратно клиенту путем записи в HHTPServletResponse.getOutputStream (). Затем в клиенте, когда SOAPMessage преобразуется в строку, структура XML такая же, как и в классе обслуживания, но getAttachments () возвращает значение null, а атрибут вложения объекта SOAPMessage равен null. Вот фрагмент кода класса обслуживания, который формирует SOAP сообщение

String attachment1 = "some string";
AttachmentPart attachPart1 = drResponse.createAttachmentPart(attachment1, "text/plain");
attachPart1.setMimeHeader("Content-Transfer-Encoding", "binary");// This i have commented also to debug
SOAPMessgaeObject.addAttachmentPart(attachPart1);// SOAPMessage object has SOAP body

После SOAP XML при печати в классе обслуживания

------=_Part_39_1068860754.1583911190353
Content-Type: application/soap+xml; charset=utf-8

<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
    <soap:Header><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" soap:mustUnderstand="true"><wsse11:SignatureConfirmation xmlns:wsse11="http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd" Value="bEppWTc4ZkloMjl4K3BSR3NLYkN1R2NKOFBZb2VLRnZPc04xdkJ2bm80UzIwZ0ZwWkVJS24vYlRLWVdudldZM2xxWWE2NDg0OTcxV282OU4xdHM3UWRiOGorbW9LaWhRUkkzS3c2L0FJUkJsMWxSNk00SG9EUDlUNjNVTGxTRUVMejVBN0NMa2tyMUE4SzlDeVdZWW1IeEp1dHRaUjZmbXVzNXRsZEkvMUhTSWdLZEVMWjFSZUNHckpDazhTK2FpM2x4ZzBxaUpkd0NHVzd1RkFZeW1YVUtkWVF2SmROZlZWMXNQVHVzNmtLT1VxaEZFK2NxY29rd2pCTzlWekQ0ZGVhSWpNOFZ3WGJjU2tNTEwxekwvbXlUajlxUXd1aGdCcUxSNEE5dTZ0N1RwOGtGTUdTaERjMUlZaExOMXRMWGU2WU9BQWNUUW92WDRsWEUySldrWWNnPT0=" wsu:Id="SC-6771a049-6eae-4683-b640-08e7875236d8"/><wsu:Timestamp wsu:Id="TS-8281552e-f59b-4582-bfa2-34a5f56d9a75"><wsu:Created>2020-03-11T07:19:50.346Z</wsu:Created><wsu:Expires>2020-03-11T07:24:50.346Z</wsu:Expires></wsu:Timestamp></wsse:Security>
        <Action xmlns="http://www.w3.org/2005/08/addressing" soap:mustUnderstand="true">urn:ihe:iti:2007:CrossGatewayRetrieveResponse</Action>
        <To xmlns="http://www.w3.org/2005/08/addressing">http://www.w3.org/2005/08/addressing/anonymous</To>
    <MessageID xmlns="http://www.w3.org/2005/08/addressing">95fa086c-8903-44e3-b6e4-a17fdb748b5a</MessageID><RelatesTo xmlns="http://www.w3.org/2005/08/addressing">9e70687f-aae9-418f-a002-ef2e522f6af5</RelatesTo></soap:Header>
    <soap:Body>
        <RetrieveDocumentSetResponse xmlns="urn:ihe:iti:xds-b:2007" xmlns:ns2="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0" xmlns:ns3="urn:oasis:names:tc:ebxml-regrep:xsd:rs:3.0" xmlns:ns4="urn:oasis:names:tc:ebxml-regrep:xsd:query:3.0" xmlns:ns5="urn:oasis:names:tc:ebxml-regrep:xsd:lcm:3.0">
            <ns3:RegistryResponse status="urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Success"/>
            <DocumentResponse>
                <HomeCommunityId>urn:oid:urn:oid:2.16.840.1.113883.3.109.3.0.2.2.6</HomeCommunityId>
                <RepositoryUniqueId>2.16.840.1.113883.3.109.3.0.2.2.3</RepositoryUniqueId>
                <DocumentUniqueId>2.16.840.1.113883.3.109.3.9038.1.1.1.80210.2.2.3.3979</DocumentUniqueId>
                <mimeType>text/xml</mimeType>
                <Document>
                    <xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:b9e47d0a-77b1-4ae8-ab68-95f9ae4081f6@urn%3Aihe%3Aiti%3Axds-b%3A2007"/>
                </Document>
            </DocumentResponse>
        </RetrieveDocumentSetResponse>
    </soap:Body>
</soap:Envelope>
------=_Part_39_1068860754.1583911190353
Content-Type: text/xml
Content-Transfer-Encoding: binary

<?xml version="1.0"?><?xml-stylesheet type='text/xsl' href='http://www.nextgenshare.com/public/cda_ngmu2.xsl'?><Emp id="1"><name>Pankaj</name><age>25</age><role>Developer</role><gen>Male</gen></Emp>
------=_Part_39_1068860754.1583911190353--
Final statusCode : 200
CCD CONTENT : PD94bWwgdmVyc2lvbj0iMS4wIj8+PD94bWwtc3R5bGVzaGVldCB0eXBlPSd0ZXh0L3hzbCcgaHJl
Zj0naHR0cDovL3d3dy5uZXh0Z2Vuc2hhcmUuY29tL3B1YmxpYy9jZGFfbmdtdTIueHNsJz8+PEVt
cCBpZD0iMSI+PG5hbWU+UGFua2FqPC9uYW1lPjxhZ2U+MjU8L2FnZT48cm9sZT5EZXZlbG9wZXI8
L3JvbGU+PGdlbj5NYWxlPC9nZW4+PC9FbXA+

метод getAttachments () работает здесь

Вот сообщение, полученное в конечной точке клиента

------=_Part_44_183853970.1583911258396
Content-Type: application/soap+xml; charset=utf-8

<?xml version="1.0" encoding="UTF-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
    <soap:Header><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" soap:mustUnderstand="true"><wsse11:SignatureConfirmation xmlns:wsse11="http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd" Value="UGkxWjVaQjdpTmVxNUl0cUhXT1JtVFJPbjlhNkt4WjYwY0RWUzNVZlpHL1ZaQ0pkcWt5Um85cXFka0RDTHlXNk80cmIydjNPOWVweHlEcnpvZWhNU0wvbS9WdTFZTGNIZFhXQ0hLZFk3ZytwMkJvUEkvMXhuWHk3S3dDRTVHYkpoRlJLU2ZudEkvNnU5M0hPUGFxNUVyT2xkTnVtRW11djcvTnYxZXFJSVc3NGdLUXk1MnhTdjBHbnpNMXYyZzB2Uktsd0trYU5XaGpFdnNxWUNzKzBvUGphcWhQTGFxOFVYZ2N6em4wRWFQdFJjWTRyZjdGN0pSSTdFZzNoRW5NZWMrTzAxMjhER0hPUG9Ec0RaQ1VPR2U1M21DdWZLR0dmVnBPRmhSTEtDajJheWlnN3Rwb2pBYkdPZ3Z5TktzQlAxNkROYzlVK3JyaUhsczFLUW55bWFBPT0=" wsu:Id="SC-7aef8985-dde4-4389-b6d5-439362e75fe2"/><wsu:Timestamp wsu:Id="TS-7b958212-66fc-44e2-8181-f998c7cc6db6"><wsu:Created>2020-03-11T07:20:58.383Z</wsu:Created><wsu:Expires>2020-03-11T07:25:58.383Z</wsu:Expires></wsu:Timestamp></wsse:Security>
        <Action xmlns="http://www.w3.org/2005/08/addressing" soap:mustUnderstand="true">urn:ihe:iti:2007:CrossGatewayRetrieveResponse</Action>
        <To xmlns="http://www.w3.org/2005/08/addressing">http://www.w3.org/2005/08/addressing/anonymous</To>
    <MessageID xmlns="http://www.w3.org/2005/08/addressing">6c8bb926-0b17-412c-87bb-984b35219d16</MessageID><RelatesTo xmlns="http://www.w3.org/2005/08/addressing">1ebae448-2709-47bc-b3cb-debaa306acfb</RelatesTo></soap:Header>
    <soap:Body>
        <RetrieveDocumentSetResponse xmlns="urn:ihe:iti:xds-b:2007" xmlns:ns2="urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0" xmlns:ns3="urn:oasis:names:tc:ebxml-regrep:xsd:rs:3.0" xmlns:ns4="urn:oasis:names:tc:ebxml-regrep:xsd:query:3.0" xmlns:ns5="urn:oasis:names:tc:ebxml-regrep:xsd:lcm:3.0">
            <ns3:RegistryResponse status="urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Success"/>
            <DocumentResponse>
                <HomeCommunityId>urn:oid:urn:oid:2.16.840.1.113883.3.109.3.0.2.2.6</HomeCommunityId>
                <RepositoryUniqueId>2.16.840.1.113883.3.109.3.0.2.2.3</RepositoryUniqueId>
                <DocumentUniqueId>2.16.840.1.113883.3.109.3.9038.1.1.1.80210.2.2.3.3979</DocumentUniqueId>
                <mimeType>text/xml</mimeType>
                <Document>
                    <xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:800517d3-71b7-4cf4-a382-847833531dfe@urn%3Aihe%3Aiti%3Axds-b%3A2007"/>
                </Document>
            </DocumentResponse>
        </RetrieveDocumentSetResponse>
    </soap:Body>
</soap:Envelope>
------=_Part_44_183853970.1583911258396
Content-Type: text/xml
Content-Transfer-Encoding: binary

<?xml version="1.0"?><?xml-stylesheet type='text/xsl' href='http://www.nextgenshare.com/public/cda_ngmu2.xsl'?><Emp id="1"><name>Pankaj</name><age>25</age><role>Developer</role><gen>Male</gen></Emp>
------=_Part_44_183853970.1583911258396--

здесь getAttachments не работает

...