mvantellingen / python-zeep

A Python SOAP client
http://docs.python-zeep.org
Other
1.88k stars 583 forks source link

Name oder service not known if & between two blanks in service name #1253

Open Telmur opened 3 years ago

Telmur commented 3 years ago
  1. Zeep 4.1.0
  2. It's not a public WSDL so i can't provide it; It's a default Dynamics NAV CRONUS soap webservice running locally and you can recreate this issue with any soap web service where you have a & inbetween blanks.
import requests
import requests_ntlm
from decouple import config

soap_url = "http://192.168.2.242:7047/DynamicsNAV100/WS/CRONUS%20%26%20AG/Codeunit/HelloWorld"

soap_session = requests.Session()
soap_session.auth = requests_ntlm.HttpNtlmAuth(config('user'), config('pass'))
zeep_client = zeep.Client(soap_url, transport=zeep.transports.Transport(session=soap_session))
zeep_service = zeep_client.service
print(zeep_service.HelloWorld())

The expected behavior is printing 'Hello World' to the console, but instead it gives:

zeep.exceptions.Fault: Service "CRONUS %26 AG/Codeunit/HelloWorld" was not found!

I debugged it, and found out, that i can get my expected behavior, if i change line 248 in soap.py from this:

location = address_node.get("location")

to this:

location = address_node.base

The Problem is the & between the two blanks, it is correct, until the line 242: address_node = xmlelement.find("soap:address", namespaces=self.nsmap) After that the soap_url is wrong (%2526 instead of %26 for the escaped &):

http://192.168.2.242:7047/DynamicsNAV100/WS/CRONUS%20%2526%20AG/Codeunit/HelloWorld
jstoetzel commented 8 months ago

@mvantellingen, do you accept a merge request consisting only of the single line change mentioned above? I'm currently facing the same issue but I am unable to provide a test.

I can see that the test suite still passes after the line is changed, though.