0

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.

Community
  • 1
  • 1
JustLudo
  • 1,690
  • 12
  • 29

1 Answers1

0

You should google around for sample messages / examples. I've linked a related StackOverflow question.

SOAP with attachments is an area where there are a number of approaches and you need to be sure that you are aligning with the target service. I suggest using a tool like SOAPUI to help craft the message payloads, which you can then test manually. Once you have the format down, constructing in Python should be straight forward-- either using an existing Python SOAP library or manually as a last resort.

  1. Related SO question: How to send a file through Soap in python?
  2. SOAP UI: https://www.soapui.org/
  3. w3 spec: https://www.w3.org/TR/SOAP-attachments

Note: This is not related to ActiveMQ, as ActiveMQ will accept a text-based payload over STOMP regardless of SOAP with or without attachments. Probably a good idea to remove the ActiveMQ tag to avoid the wrath of the stack overflow custodians.

Community
  • 1
  • 1
Matt Pavlovich
  • 4,087
  • 1
  • 9
  • 17
  • Thank you for the answer. I actually already use SoapUI to test out certain functionality but I forgot to mention that. Also, I will try to explain a little more in my opening post tomorrow where I got "stuck". First let me read the specifications provided. – JustLudo Jan 18 '17 at 16:04
  • I have edited the original question with a more precise description. Hopefully this is just something obvious which can be easily pointed out. – JustLudo Jan 19 '17 at 13:33