Skip to content

module 'suds' has no attribute 'metrics' in suds/sax/parser.py #118

@fenuks

Description

@fenuks

Hello, I get

Traceback (most recent call last):
  File "/tmp/suds/test.py", line 55, in <module>
    wsdl = reader.open(url)
  File "/tmp/suds/.venv/lib/python3.13/site-packages/suds/reader.py", line 109,
in open
    wsdl = self.fn(url, self.options)
  File "/tmp/suds/.venv/lib/python3.13/site-packages/suds/wsdl.py", line 164,
in __init__
    d = reader.open(url)
  File "/tmp/suds/.venv/lib/python3.13/site-packages/suds/reader.py", line 153,
in open
    xml = self.__fetch(url)
  File "/tmp/suds/.venv/lib/python3.13/site-packages/suds/reader.py", line 202,
in __fetch
    return sax.parse(string=content)
           ~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/tmp/suds/.venv/lib/python3.13/site-packages/suds/sax/parser.py", line
124, in parse
    timer = suds.metrics.Timer()
            ^^^^^^^^^^^^
AttributeError: module 'suds' has no attribute 'metrics'

Steps to reproduce:

  1. Run
mkdir /tmp/suds
cd /tmp/suds
python3 -m venv .venv
source .venv/bin/activate
pip install git+https://github.com/suds-community/suds
  1. Create test.py file in /tmp/suds
# example WSDL taken from https://en.wikipedia.org/wiki/Web_Services_Description_Language
wsdl = '''
<?xml version="1.0" encoding="UTF-8"?>
<description xmlns="http://www.w3.org/ns/wsdl" xmlns:tns="http://www.tmsws.com/wsdl20sample" xmlns:whttp="http://schemas.xmlsoap.org/wsdl/http/" xmlns:wsoap="http://schemas.xmlsoap.org/wsdl/soap/" targetNamespace="http://www.tmsws.com/wsdl20sample">
  <documentation>
    This is a sample WSDL 2.0 document.
</documentation>
  <!-- Abstract type -->
  <types>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.tmsws.com/wsdl20sample" targetNamespace="http://www.example.com/wsdl20sample">
      <xs:element name="request"> ... </xs:element>
      <xs:element name="response"> ... </xs:element>
    </xs:schema>
  </types>
  <!-- Abstract interfaces -->
  <interface name="Interface1">
    <fault name="Error1" element="tns:response"/>
    <operation name="Get" pattern="http://www.w3.org/ns/wsdl/in-out">
      <input messageLabel="In" element="tns:request"/>
      <output messageLabel="Out" element="tns:response"/>
    </operation>
  </interface>
  <!-- Concrete Binding Over HTTP -->
  <binding name="HttpBinding" interface="tns:Interface1" type="http://www.w3.org/ns/wsdl/http">
    <operation ref="tns:Get" whttp:method="GET"/>
  </binding>
  <!-- Concrete Binding with SOAP-->
  <binding name="SoapBinding" interface="tns:Interface1" type="http://www.w3.org/ns/wsdl/soap" wsoap:protocol="http://www.w3.org/2003/05/soap/bindings/HTTP/" wsoap:mepDefault="http://www.w3.org/2003/05/soap/mep/request-response">
    <operation ref="tns:Get"/>
  </binding>
  <!-- Web Service offering endpoints for both bindings-->
  <service name="Service1" interface="tns:Interface1">
    <endpoint name="HttpEndpoint" binding="tns:HttpBinding" address="http://www.example.com/rest/"/>
    <endpoint name="SoapEndpoint" binding="tns:SoapBinding" address="http://www.example.com/soap/"/>
  </service>
</description>
'''
wsdl_file = '/tmp/test.wsdl'
with open(wsdl_file, 'w', encoding='utf-8') as fp:
    fp.write(wsdl)


import suds
from suds.options import Options
from suds.reader import DefinitionsReader
from suds.wsdl import Definitions
import suds.transport.https


options = Options()
options.transport = suds.transport.https.HttpAuthenticated()

reader = DefinitionsReader(options, Definitions)
url = f'file://{wsdl_file}'
wsdl = reader.open(url)
  1. Run it.
python3 test.py

It seems that import suds.metrics is missing from suds/sax/parser.py file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions