我是python的noob,但现在我必须为我的webservice调用创建一个示例python(v2.7)代码。它似乎有效,但当我打开" Windows身份验证"在这个webapp的IIS上,它停止了工作。我用过SUDS库。请帮助添加auth信息以调用我的webservice。提前谢谢!
import suds
import urllib2
import logging
from suds.transport.http import HttpAuthenticated
from suds.client import Client
##*************************************************************************
wsdlloc = 'http://myserver.com/myWebService.asmx'
wsdlurl = wsdlloc+'?wsdl'
login="test"
pwd="test123"
##*************************************************************************
if True:
logging.basicConfig(level=logging.DEBUG)
logging.getLogger('suds').setLevel(logging.DEBUG)
##-------------------
##--- IT IS WORKING WHEN NO WINDOWS AUTHENTICATION IS NEEDED
if False:
c = Client(url=wsdlurl)
list = c.service.myFunc("2014-05-08","2014-05-28")
print( list )
##--- IT GENERATES "suds.transport.TransportError: HTTP Error 401: Unauthorized"
if True:
trnsport = suds.transport.http.HttpAuthenticated(username=login, password=pwd)
client = Client(url=wsdlurl, username=login, password=pwd, transport=trnsport)
list = client.service.myFunc("2014-05-08","2014-05-28")
print( list )
答案 0 :(得分:1)
必须使用WindowsHttpAuthenticated(..),而不是HttpAuthenticated(...):(对不起我的noob问题。