2013-11-22 115 views
1

我也有SOAP問題。我正在嘗試使用帶SUDS的python實現一個接口。LexisNexis SUDS SOAP請求

我想創建一個應用程序來驗證和搜索在Python中的LexisNexis。所以如果有人知道這是否已經實施,那也會很棒。我已經搜索了很多東西,並找到了這個網站:https://hkn.eecs.berkeley.edu/~dhsu/hacks.shtml,這很好,但沒有SOAP代碼。

我迄今所做的:

我知道信封應該是這樣的:

<?xml version="1.0" encoding="utf-8"?> 
<soap:Body xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
    <Authenticate xmlns="http://authenticate.authentication.services.v1.wsapi.lexisnexis.com"> 
    <authId>id</authId> 
    <password>password</password> 
    </Authenticate> 
</soap:Body> 

我可以構建它(我認爲)

from suds.sax.element import Element 

    authentication = Element('Authenticate') 
    authentication.set('xmlns','http://authenticate.authentication.services.v1.wsapi.lexisnexis.com') 

    authId = Element('authId').setText('authId') 

    password = Element('password').setText('password') 

    authentication.append(authId) 
    authentication.append(password) 

    print authentication 

返回:

<Authenticate xmlns="http://authenticate.authentication.services.v1.wsapi.lexisnexis.com"> 
    <authId>authId</authId> 
    <password>password</password> 
</Authenticate> 

但是,我無法讓客戶工作。我給出這樣的信息:

模式
- Authentication.xsd

目標命名空間
- http://authenticate.authentication.services.v1.wsapi.lexisnexis.com

命名空間表

我可能這樣做不對,但我曾嘗試:

client = Client('http://authenticate.authentication.services.v1.wsapi.lexisnexis.com') 

imp = Import('http://www.w3.org/2001/XMLSchema', 
       location='http://www.w3.org/2001/XMLSchema.xsd') 
imp.filter.add('http://security.common.services.v1.wsapi.lexisnexis.com') 
wsdl_url = 'http://authenticate.authentication.services.v1.wsapi.lexisnexis.com' 
client = Client(wsdl_url, doctor=ImportDoctor(imp)) 

但是都導致

<urlopen error [Errno 8] nodename nor servname provided, or not known> 

對不起,這是我第一次和LexisNexis api是相當粗糙的新手與SUDS。

非常感謝

回答

0

你的錯誤有一點做與suds,以及一切與底層urllib連接請求:

<urlopen error [Errno 8] nodename nor servname provided, or not known> 

此錯誤是常見的,當主機名是不正確的,或者根本沒有迴應。這是一個簡單的例子:

import urllib 
urllib.urlopen(u'http://authenticate.authentication.services.v1.wsapi.lexisnexis.com') 

這也失敗了!檢查您的網址,然後重試。

0

LexisNexis爲API開發人員提供了一個WSDL文件,以及他們的用戶名和密碼。您必須確保您使用的是此WSDL。要使用SUDS在本地訪問WSDL文件,請輸入url作爲文件://path/to/file.wsdl