2011-07-07 17 views
1

私はeBayのfindItemsByKeywordsメソッドを呼び出すようにしようとしていますし、私はサーバー上げ障害を得る: 'SOA操作名ヘッダー行方不明':イーベイのSOAPのAPI - ミッシングSOAオペレーション名ヘッダ

from config import * 

# url = 'http://developer.ebay.com/webservices/latest/ebaySvc.wsdl' 
# url = 'http://svcs.ebay.com/services/search/BestMatchItemDetailsService/v1?wsdl' 
url = 'http://developer.ebay.com/webservices/finding/latest/FindingService.wsdl' 

from suds.client import Client 
import logging 
logging.basicConfig() 
client = Client(url) 

from suds.sax.element import Element 
ns1 = ('ns1', 'http://www.ebay.com/marketplace/search/v1/services') 
app_id = Element('X-EBAY-API-APP-ID', ns = ns1).setText(EBAY_API_APP_ID) 
operation_name = Element('X-EBAY-SOA-OPERATION-NAME', ns = ns1).setText('findItemsByKeywords') 
api_version = Element('X-EBAY-API-VERSION', ns = ns1).setText(EBAY_APP_VERSION) 
site_id = Element('X-EBAY-API-SITE-ID', ns = ns1).setText(EBAY_API_SITE_ID) 
encoding = Element('X-EBAY-API-REQUEST-ENCODING', ns = ns1).setText('SOAP') 
service_name = Element('X-EBAY-SOA-SERVICE-NAME', ns = ns1).setText('FindingService') 
client.set_options(soapheaders = [app_id, operation_name, api_version, site_id, encoding, service_name]) 

print client.service.findItemsByKeywords(keywords = 'book') 

が、それはプリントを:

<SOAP-ENV:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.ebay.com/marketplace/search/v1/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> 
    <SOAP-ENV:Header> 
     <ns1:X-EBAY-API-APP-ID>123456-1234-1234-1234-7876b3f33c3</ns1:X-EBAY-API-APP-ID> 
     <ns1:X-EBAY-SOA-OPERATION-NAME>findItemsByKeywords</ns1:X-EBAY-SOA-OPERATION-NAME> 
     <ns1:X-EBAY-API-VERSION>721</ns1:X-EBAY-API-VERSION> 
     <ns1:X-EBAY-API-SITE-ID>0</ns1:X-EBAY-API-SITE-ID> 
     <ns1:X-EBAY-API-REQUEST-ENCODING>SOAP</ns1:X-EBAY-API-REQUEST-ENCODING> 
     <ns1:X-EBAY-SOA-SERVICE-NAME>FindingService</ns1:X-EBAY-SOA-SERVICE-NAME> 
    </SOAP-ENV:Header> 
    <ns0:Body> 
     <ns1:findItemsByKeywordsRequest> 
     <ns1:keywords>book</ns1:keywords> 
     </ns1:findItemsByKeywordsRequest> 
    </ns0:Body> 
</SOAP-ENV:Envelope> 
Traceback (most recent call last): 
    File "wsdl.py", line 22, in <module> 
    print client.service.findItemsByKeywords(keywords = 'book') 
    File "/ebay/suds/client.py", line 542, in __call__ 
    return client.invoke(args, kwargs) 
    File "/ebay/suds/client.py", line 602, in invoke 
    result = self.send(soapenv) 
    File "/ebay/suds/client.py", line 657, in send 
    result = self.failed(binding, e) 
    File "/ebay/suds/client.py", line 712, in failed 
    r, p = binding.get_fault(reply) 
    File "/ebay/suds/bindings/binding.py", line 265, in get_fault 
    raise WebFault(p, faultroot) 
suds.WebFault: Server raised fault: 'Missing SOA operation name header' 

答えて

3

ebay-python, unofficial python wrapper for eBay APIを使用してください。使い方が簡単でなく機能します。独自のものを使用する場合は、リクエストの作成方法に関するソースコードも参照できます。

+0

の作品、私は取引API(AddFixedPriceItem)を必要とする...ノートがあります:私たちは今の取引APIと大マーチャント・サービスを実装することはありません。 – Etam

+0

ああ、私の悪い。すぐにそのメソッドを実装しようとします。 – zengr

+0

これを実装しgithubでプルリクエストを送信した場合は素晴らしいでしょう。ここで参照実装を見ることができます:https://github.com/roopeshvaddepally/python-ebay/blob/master/ebay/finding.py – zengr

0

同じことをしようとしているvb.netコードでこのエラーが発生しましたが、間違ったAppIDを使用していたことが判明しました。私はサンドボックスのURLでライブのものを使用していましたが、それを切り替えても問題ありませんでした。

0

私はこのコードを使用し、それが

headers={'X-EBAY-SOA-OPERATION-NAME':'findItemsByKeywords', 
       'X-EBAY-SOA-SECURITY-APPNAME': 'your-key'} 

client = Client(url,headers=headers)