દૂરના WSDL થી Zeep Client બનાવવાથી તે દસ્તાવેજ અને તેના import તરત જ આવી શકે છે. Client એ service description લોડ કરવાનો પ્રયાસ કર્યા પછી પ્રોક્સી સેટ કરવાને બદલે પહેલાં Transport ગોઠવો.

from requests import Session
from zeep import Client
from zeep.transports import Transport

session = Session()
session.proxies.update({
    "http": "http://proxy.example.net:8080",
    "https": "http://proxy.example.net:8080",
})

transport = Transport(
    session=session,
    timeout=10,
    operation_timeout=30,
)
client = Client(wsdl_url, transport=transport)

wsdl_url એ service-description નું ખરેખર URL છે. જો તે service અને તેના import જાહેરમાં ઉપલબ્ધ હોય અને જાહેર પ્રોક્સીની મંજૂરી હોય, તો HTTP proxy list સત્રના proxy URL માટે ઉમેદવારો પૂરા પાડે છે. પછીના SOAP operations માટે ગોઠવેલું સત્ર ચાલુ રાખો, અને તે કામ પૂરું થાય ત્યારે તેને બંધ કરો.

Transport.timeout WSDL અને XSD લોડ કરવાનું નિયંત્રણ કરે છે. operation_timeout service operations માટે થતી HTTP વિનંતીઓ નિયંત્રિત કરે છે. તેથી Client બનાવતી વખતે metadata timeout એ પછી method call timeout થવાથી અલગ તબક્કો છે.

આ ઉદાહરણમાં Requests નું environment integration સક્રિય રહે છે. જો environment proxy મૂલ્યો સ્પષ્ટપણે જરૂરી route સાથે વિરોધ કરે, તો session.trust_env=False વાપરો અને જરૂરી CA bundle અને authentication સેટિંગ્સ સ્પષ્ટ રીતે આપો.

જો ઇનિશિયલાઇઝેશન હજી પણ નિષ્ફળ જાય તો import કરેલા દસ્તાવેજનું URL તપાસો. ટોચના સ્તરનું WSDL સફળતાપૂર્વક લોડ થઈ શકે છે જ્યારે import કરેલું schema બીજું hostname અથવા ગંતવ્ય protocol વાપરે છે.

સંબંધિત લેખો