# How to send SOAP messages with attachments?

**URL:** https://talk.remobjects.com/t/how-to-send-soap-messages-with-attachments/22419
**Category:** Remoting SDK
**Tags:** delphi, soap
**Created:** [June 25, 2020, 5:54pm UTC](https://talk.remobjects.com/t/how-to-send-soap-messages-with-attachments/22419 "2020-06-25T17:54:01Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![incspn](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/i/a183cd/32.png) [@incspn](https://talk.remobjects.com/u/incspn)
#### Post date: [June 25, 2020, 5:54pm UTC](https://talk.remobjects.com/t/how-to-send-soap-messages-with-attachments/22419/1 "2020-06-25T17:54:01Z")

</div>

I am consuming a web service using an interface automatically generated from a RODL file.  
Is there a way to send attachments using the CID URI scheme?

Thanks

---

<div class="post-metadata">

### Author: ![EvgenyK](https://talk.remobjects.com/user_avatar/talk.remobjects.com/evgenyk/32/16_2.png) [@EvgenyK](https://talk.remobjects.com/u/EvgenyK)
#### Post date: [June 26, 2020, 9:05am UTC](https://talk.remobjects.com/t/how-to-send-soap-messages-with-attachments/22419/2 "2020-06-26T09:05:52Z")

</div>

Hi,

can you show example of such SOAP request, pls?  
you can use support@ for keeping privacy

---

<div class="post-metadata">

### Author: ![incspn](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/i/a183cd/32.png) [@incspn](https://talk.remobjects.com/u/incspn)
#### Post date: [June 26, 2020, 4:23pm UTC](https://talk.remobjects.com/t/how-to-send-soap-messages-with-attachments/22419/3 "2020-06-26T16:23:55Z")

</div>

Sure,  
The raw request should be as follows:

```
--uuid:7b317f0c-6225-4596-84d1-5d53e7a1a28a
Content-Id: <rootpart*7b317f0c-6225-4596-84d1-5d53e7a1a28a@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"?>
<SOAP-ENV:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:HNS="http://tempuri.org/"
    xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:v1="http://service _____________.com/wsdl">
    <SOAP-ENV:Header />
    <SOAP-ENV:Body xmlns:ro="http://www.w3.org/2001/XMLSchema-instance">
        <v1:MessageSubmission>
            <v1:Login>
                ...
                ...
                ...
            </v1:Login>
            <v1:SubmitMessageRequest>
                ...
                ...
                <v1:AttachmentFile>
                    <v1:href>cid:243bc04e-faa1-4de1-9da2-fc0a024d1db5@example.jaxws.sun.com</v1:href>
                </v1:AttachmentFile>
            </v1:SubmitMessageRequest>
        </v1:MessageSubmission>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

--uuid:7b317f0c-6225-4596-84d1-5d53e7a1a28a
Content-Id: <243bc04e-faa1-4de1-9da2-fc0a024d1db5@example.jaxws.sun.com>
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary

    ... data (binary or text) ...
-uuid:7b317f0c-6225-4596-84d1-5d53e7a1a28a--

```

Here are some references:

[https://en.wikipedia.org/wiki/XML-binary\_Optimized\_Packaging#Usage\_in\_SOAP\_Web\_services](https://en.wikipedia.org/wiki/XML-binary_Optimized_Packaging#Usage_in_SOAP_Web_services)  
[https://docs.roguewave.com/hydraexpress/4.6.0/html/rwsfwsdevug/17-2.html](https://docs.roguewave.com/hydraexpress/4.6.0/html/rwsfwsdevug/17-2.html)  
[https://docs.microfocus.com/SM/9.60/Codeless/Content/webservicesguide/reference/attachment\_operations\_using\_SOAP\_API.htm](https://docs.microfocus.com/SM/9.60/Codeless/Content/webservicesguide/reference/attachment_operations_using_SOAP_API.htm)

Thanks for help!

---

<div class="post-metadata">

### Author: ![EvgenyK](https://talk.remobjects.com/user_avatar/talk.remobjects.com/evgenyk/32/16_2.png) [@EvgenyK](https://talk.remobjects.com/u/EvgenyK)
#### Post date: [June 30, 2020, 10:12am UTC](https://talk.remobjects.com/t/how-to-send-soap-messages-with-attachments/22419/4 "2020-06-30T10:12:47Z")

</div>

Hi,

this feature isn’t supported, but you can do it manually:  
you can use [Channel.OnSendStream](https://docs.remotingsdk.com/API/Delphi/Classes/TROTransportChannel/#OnSendStream) event and modify stream that will be sent to server.

for adding attachment you can use class from `uROMime.pas` unit
