0

セットアップで泡が機能しないようです。API の関数を使用する前に、リモート ユーザーを設定してコンテキストを渡す必要があります。私がやろうとしたことはこれでした:

client = Client(url, username=userid, password=password)
apiContext = client.factory.create("apiCallContext")     # This is listed in the types
apiContext.remoteUser = "serviceAccount"                 # when I print the client

client.set_options(soapheaders=apiContext)
client.service.getActiveIPs()

プロセス全体を通して、すべてが正しく作成されているように見えます (クライアントを印刷すると、すべての関数と型が表示され、apiContext を印刷すると、すべてが正しく設定されていることがわかります)、ヘッダーは実際には設定されていないようです。 :

...
DEBUG:suds.client:sending to ($URL) message:
  <?xml version="1.0" encoding="UTF-8"?>
  <SOAP-ENV:Envelope xmlns:ns0=$NS 
                     xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/"
                     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                     xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
  <SOAP-ENV:Header/>
  <ns1:Body>
    <ns0:getActiveIPs/>
  </ns1:Body>
  </SOAP-ENV:Envelope>
DEBUG:suds.client:headers = {'SOAPAction': u'""', 
                             'Content-Type': 'text/xml; charset=utf-8'}
DEBUG:suds.transport.http:sending:
  URL:$URL
  HEADERS: {'SOAPAction': u'""', 'Content-Type': 'text/xml; charset=utf-8', 
            'Content-type': 'text/xml; charset=utf-8', 'Soapaction': u'""'}
...

ヘッダーのどこにもコンテキストが表示されず、サーバーはリモート ユーザー セットがないというエラーを出しています。

私は何を間違っていますか?

4

1 に答える 1

1

使用している Web サービスの正確な仕様がわからないので、この回答を推測することしかできませんが、ヘッダーは過去に使用した Web サービスに似ています。要素を直接作成してヘッダーに渡してみましたか?:

from suds.sax.element import Element
...
NS = ('h', SOME_NAMESPACE)
apiContext = Element('apiContext')
authcred = Element('authenticationCredential', ns=NS)
username = Element(userid, ns=NS).setText('USERNAME')
passw = Element(password, ns=NS).setText('PASSWORD')
authcred.append(username)
authcred.append(passw)
apiContext.append(authcred)
client.set_options(soapheaders=apiContext)

つまり、コンテキスト オブジェクトの認証部分ですか。

于 2010-11-12T12:02:17.930 に答える