zeep.exceptions.Fault: service not found

60 Views Asked by At

I'm trying to get a custom business central soap endpoint to work. My setup:

import os
from requests import Session
from requests.auth import HTTPBasicAuth

from zeep import Client
from zeep.transports import Transport

user = os.environ.get("BC_USER")
password = os.environ.get("BC_PASSWORD")

session = Session()
session.auth = HTTPBasicAuth(user, password)

url = "https://foo.bar/Company%20Name/Codeunit/MyOperation"

client = Client(url, transport=Transport(session=session))

client.service.MyOperation("baz")

results in

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/j/.local/lib/python3.8/site-packages/zeep/proxy.py", line 46, in __call__
    return self._proxy._binding.send(
  File "/home/j/.local/lib/python3.8/site-packages/zeep/wsdl/bindings/soap.py", line 135, in send
    return self.process_reply(client, operation_obj, response)
  File "/home/j/.local/lib/python3.8/site-packages/zeep/wsdl/bindings/soap.py", line 229, in process_reply
    return self.process_error(doc, operation)
  File "/home/j/.local/lib/python3.8/site-packages/zeep/wsdl/bindings/soap.py", line 329, in process_error
    raise Fault(
zeep.exceptions.Fault: Service "Company Name/Codeunit/MyOperation" was not found!

python3 -m zeep "https://foo.bar/Company%20Name/Codeunit/MyOperation" returns

Prefixes:
     xsd: http://www.w3.org/2001/XMLSchema
     ns0: urn:microsoft-dynamics-schemas/codeunit/MyOperation

Global elements:
     
     ns0:MyOperation(serialNo: xsd:string)
     ns0:MyOperation_Result(return_value: xsd:string)

Global types:
[...]

Bindings:
     Soap11Binding: {urn:microsoft-dynamics-schemas/codeunit/GetItemOptionsFromSerial}MyOperation_Binding

Service: MyOperation
     Port: MyOperation_Port (Soap11Binding: {urn:microsoft-dynamics-schemas/codeunit/MyOperation}MyOperation_Binding)
         Operations:
            MyOperation(serialNo: xsd:string) -> return_value: xsd:string

So it seems the OperationProxy calls company/codeunit/myoperation instead of myoperation. Am I missing a binding? Or am I supposed to create a new service? I also tried to call the service deliberately without its argument to "prove its existence":

client.service.MyOperation()
zeep.exceptions.ValidationError: Missing element "baz" (MyOperation.baz)
1

There are 1 best solutions below

0
On

Solved! The error was in fact in zeep, see https://github.com/mvantellingen/python-zeep/issues/1253