Currently I'm using the STOMP library (http://jasonrbriggs.github.io/stomp.py) for python to send and receive SOAP messages stored on an ActiveMQ instance. This ActiveMQ is connected to a WSO2 ESB which has been configured to basically rearrange messages in different boxes based on their content type and/or SoapAction.
I'm working in a piece of python software at the moment and only have access to this ActiveMQ using a certain account. I am expected to send and receive to the queue's using stomp.py . I did this succesfully both ways using only SOAP messages. I would construct the body in XML and left the headers empty.
Now the question was asked to use SOAP with Attachments (SwA) instead, since attachments are required as well. I know the system that ultimately receives these messages does not yet handle MTOM, so I'm left with sending out SwA messages.
I provided the content-type in the header with application/octet-stream already, but I cannot for the life of me figure out how to actually incorporate the files themselves in these messages.
To send out the messages I construct the XML body, headers in dictionary form and use this piece of code:
conn = self._build_connection()[0]
destination = self.subscription_id.queue_name
# Connect to the server
conn.connect(username=self.env.user.company_id.login_name, password=self.env.user.company_id.password)
# Send the actual message out
conn.send(destination, self.body, headers=self.header)
conn.disconnect()
"_build_connection" just provides me with a connection to the ActiveMQ queue required. If this is relevant to the answer let me know.
I have the feeling I'm pretty close to a working solution but I simply fail the so the missing link. ------------------ EDIT----------------
I see now I was looking in the wrong direction. Inserting attachments into SOAP messages is my problem, not getting the messages to ActiveMQ. I also noticed that the message will be a single file/call to ActiveMQ so I need to rephrase my question.
That said I am currently trying to figure out how to work with PySimpleSoap to construct my message. Will update once this has worked.
------------------ EDIT2 ----------------
A rephrase of my question. Suppose I have this simple soap message which I created using the standard ElementTree library for Python:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tec="someURLtech">
<soapenv:Header/>
<soapenv:Body>
<tec:SomethingTechnical>
<tec:SomeValue>140</tec:SomeValue>
</SomethingTechnical>
</soapenv:Body>
</soapenv:Envelope>
And I wanted to have a an attachment added to this using SwA, I would have to make sure it is somehow inside the envelop.
I have already found this link to another question on the differences between SwA and MTOM but I simply fail to see where I should indicate that the file in question is indeed an image (for example) and where to put the actual base64 encoded data for it. Note: I know how to get these, I'm simply asking on how to position these is in a way that is accepted within XML.
The reason for asking is that the target application WSDL (which unfortunately I'm not allowed to share) does have a tag for attachments but no tag for the actual data (like ) or something similar.
Again, I have the feeling I'm completely missing the point here and would be gratefull if someone could explain.
Also note that I just need to makeup the message according to the WSDL provided, not actually use the webservice. I will post said message on the ESB in ActiveMQ. I am trying to use PySimpleSoap but run into different problems there as well, so I'm not getting past verifying the WSDL file.