0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Python + ZeepでGaroon SOAP APIからユーザー情報取得

Last updated at Posted at 2019-12-10

備忘録。

xsdの部分で何日か詰まったので自分用にメモ。

###参照
【cybozu developer network】Garoon SOAP APIの共通仕様
https://developer.cybozu.io/hc/ja/articles/202228464
【cybozu developer network】ユーザー情報を取得する
https://developer.cybozu.io/hc/ja/articles/202283324

###ソース


from zeep import Client
from zeep import xsd

client = Client(wsdl='https://(サブドメイン名).cybozu.com/g/index.csp?WSDL')

header = xsd.ComplexType([
                xsd.Element('Action', xsd.String()),
                xsd.Element('Security', 
                    xsd.ComplexType([xsd.Element(
                        'UsernameToken',
                        xsd.ComplexType([
                            xsd.Element('Username', xsd.String()),
                            xsd.Element('Password', xsd.String()),
                        ])
                    )]
                )),

                xsd.Element('Timestamp', 
                    xsd.ComplexType([
                        xsd.Element('Created', xsd.String()),
                        xsd.Element('Expires', xsd.String()),
                    ])
                ),

                xsd.Element('Locale', xsd.String()),
            ])

header_value = header(
        Action="BaseGetUsersById", 
        Security={'UsernameToken':{'Username':'','Password':''}}, 
        Timestamp={'Created':'2010-08-12T14:45:00Z','Expires':'2037-08-12T14:45:00Z'},
        Locale="jp")

request_data  = {
    'parameters': {'user_id':[3, 4, 5]}
}
try:
    response = client.service.BaseGetUsersById(**request_data, _soapheaders=[header_value])
except:
    import traceback
    traceback.print_exc()

###出力結果
list型で返却される

[{
    'photo': None,
    'organization': [
        {
            'id': 'x',
            '_attr_1': {
        }
        }
    ],
    'acl': None,
    '_value_1': None,
    'key': '6',
    'version': 'XXXX',
    'order': XXXX,
    'name': 'XXXX',
    'status': 0,
    'reading': 'XXXXXXX',
    'url': None,
    'email': 'xxxxx@xxxx.co.jp',
    'phone': 'xxx-xxxx-xxxx',
    'birth_date': '1970-01-01',
    'join_date': '1970-01-01',
    'employee_number': None,
    'extension_number': None,
    'employment_pattern': None,
    'title': None,
    'office': None,
    'description': None,
    'primary_organization': '0',
    '_attr_1': {
        'login_name': 'xxxx'
    }
}]

・サブドメインの変更
・request_dataのidは適当に変える。
・header_valueのUsernameとPasswordの値を入力する。

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?