-
-
Notifications
You must be signed in to change notification settings - Fork 610
Open
Description
Using zeep 4.3.2:
I'm not that deep into soap etc so I hope I'm not missing something, or my SOAP server is not doing something stupid. I get a binary response from a SOAP service which with zeep is missing a trailing newline (I know this because I also get a signature of the content in the response, and adding a newline makes the signature verification pass).
Here is an example based on the zeep test suite:
from requests_toolbelt.multipart.decoder import MultipartDecoder
from pretend import stub
from zeep.wsdl.attachments import MessagePack
data = "\r\n".join(
line.strip()
for line in """
--MIME_boundary
Content-Type: application/soap+xml; charset=UTF-8
Content-Transfer-Encoding: 8bit
Content-ID: <root@test>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"/>
--MIME_boundary
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
Content-ID: <attachment@test>
hello world
--MIME_boundary--
""".splitlines()
).encode("utf-8")
response = stub(
status_code=200,
content=data,
encoding=None,
headers={
"Content-Type": 'multipart/related; boundary=MIME_boundary; type="application/soap+xml"; start="<root@test>"'
},
)
decoder = MultipartDecoder(response.content, response.headers["Content-Type"], "utf-8")
part = decoder.parts[1]
actual = MessagePack(decoder.parts[1:]).attachments[0].content
expected = b"hello world\r\n"
assert actual == expected, f"Expected {expected!r}, got {actual!r}"I see that these are removed in
python-zeep/src/zeep/wsdl/attachments.py
Line 78 in 368861c
| return content.strip(b"\r\n") |
thanks for zeep!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels