2013-08-19 56 views
0

我想獲得一個在efay api中使用coldfusion的示例。我沒有使用沙箱變量,而是使用我生成的生產變量。我在網上並沒有看到大量的CF例子,而易趣開發者網站對我來說很混亂。當我運行此示例時,出現以下錯誤:eBay API獲取結果示例不起作用

無法從URL讀取WSDL:http://www.ebay.com/webservices/latest/ebaySvc.wsdl

我迷失在這一點上。任何幫助將不勝感激。這裏是我試圖運行下面的例子:

<!--- set some vars ---> 
<cfset endpoint="https://api.ebay.com/wsapi"> 
<cfset callName="geteBayOfficialTime"> 
<cfset AppID="xxx"> 
<cfset DevID="xxx"> 
<cfset CertID="xxx"> 
<cfset eBayAuthToken="xxx"> <!--- this is a really long string by the way ---> 
<cfset version="419"> 
<cfset routing="default"> 
<cfset SiteID=0> 
<!--- 77 Germany, 0 USA ---> 

<cfscript> 
// get ebay wsdl file, this could take 1 -10 minutes for the first request or after a CFMX reboot 
ebayWS = CreateObject("webservice", "  http://developer.ebay.com/webservices/latest/ebaySvc.wsdl"); 
</cfscript> 

<!--- create special xml header for authentification ---> 
<cfset methodToCall = "GetSearchResults"> 
<cfsavecontent variable="ebayHeaderXML"> 
<cfoutput> 
<ebl:RequesterCredentials xmlns:ebl="urn:ebay:apis:eBLBaseComponents"> 
<ebl:eBayAuthToken>#variables.eBayAuthToken#</ebl:eBayAuthToken> 
<ebl:Credentials> 
<ebl:DevId>#variables.DevID#</ebl:DevId> 
<ebl:AppId>#variables.AppID#</ebl:AppId> 
<ebl:AuthCert>#variables.CertID#</ebl:AuthCert> 
</ebl:Credentials> 
</ebl:RequesterCredentials> 
</cfoutput> 
</cfsavecontent> 
<cfset ebayXMLObj = xmlparse(ebayHeaderXML)> 

<cfscript> 
// set the header using addSOAPRequestHeader.. an added function to CF MX 7.0 
addSOAPRequestHeader(ebayWS, "urn:ebay:apis:eBLBaseComponents", "RequesterCredentials",  "#ebayXMLObj#", false); 
</cfscript> 

<cfscript> 
// set the end point using javas _setProperty 
ebayWS._setProperty("javax.xml.rpc.service.endpoint.address","https://api.ebay.com/wsapi? callname=#methodToCall#&siteid=#SiteID#&appid=#AppID#&version=#version#&Routing=#routing#") ; 

// build geteBayqueryrequest.. 
queryrequest = StructNew(); 
queryrequest.query = "ipod nano"; 
queryrequest.version = variables.version; 
queryrequest.ExpandSearch = "True"; 
</cfscript> 

<!--- <cfscript> 
queryrequest = XmlNew(); 
queryrequest.xmlRoot = XmlElemNew(queryrequest,"GetSearchResultsRequest"); 
queryrequest.GetSearchResultsRequest.XmlChildren[1] = XmlElemNew(queryrequest,"Query"); 
queryrequest.GetSearchResultsRequest.Query.XmlText = "ipod nano"; 
</cfscript> 
<cfdump var=#queryrequest#> 
---> 
<!--- call the webservice ---> 
<cfinvoke webservice="#ebayWS#" method="#methodToCall#" returnvariable="thisRequest"> 
<cfinvokeargument name="getSearchResultsRequest" value="#queryrequest#"> 
</cfinvoke> 

<!--- save the output //---> 
<!--- <cfdump var="#thisRequest#"> ---> 
<cfdump var="#thisRequest.getSearchResultItemArray()#"> 
<cfdump var="#thisRequest.getSearchResultItemArray().getSearchResultItem()#"> 
<cfdump var="#thisRequest.getSearchResultItemArray().getSearchResultItem().getItem(1)#"> 
<cfoutput>#var#</cfoutput> 

回答

0

Ebay有時可能有點混亂,但堅持下去。

你的問題是,你正在關注的指南給出了一箇舊的/錯誤的鏈接。 (http://www.ebay.com/webservices/latest/ebaySvc.wsdl)。 當前鏈接是http://developer.ebay.com/webservices/latest/eBaySvc.wsdl。您可以在Ebay's guide pages

+0

我試過那個developer.ebay.com地址,它給了我一個無法讀取URL的WSDL:http://developer.ebay.com/webservices/latest/eBaySvc.wsdl –

+0

@JoshuaRing ebayWS = CreateObject(「webservice 「,」http://developer.ebay.com/webservices/latest/ebaySvc.wsdl「);你需要所有這些空間嗎? –

0

我已經寫在這裏提供一個開放源碼的CFC更多信息:https://github.com/a453803/cf_ebay

這給出瞭如何利用您的eBay憑據,並利用它們來處理與eBay交易的綱要。在這種情況下,這是一個時間請求,但我打算用新功能進行擴展。

看一看,讓我知道你是否需要任何幫助,或者有任何你想要實現的特定功能。