0 Replies Latest reply on Jul 10, 2006 3:27 AM by hkuperus

    A little help with Ebay SOAP web services

    hkuperus
      Hi everyone,

      I need to show ebay results one my website using a search query, for example when someone searches for "IPOD nano" the result page returns results from the EBAY SOAP web service.

      I copied the coldfusion sample from ebay coldfusion sample

      Which works fine, it returns the current time from Ebay, so I can connect to the webservice without a problem. I changed this code a little and I achieved no more then return the results by using cfdump. But cfdump only returns "com objects", but I would be so happy if someone could tell me, how to get instead of "com objects" the xml output. Actually at the code samples at Ebay there are already samples, but written in ASP or PHP. and I need that code written for coldfusionmx7.

      Anyone our there who could help me out?

      This is the output of my page so far: cfdump output

      this is the code:

      <!--- eBay API SOAP example for ColdFusion MX 7.0 (tested with windows) --->

      <!--- Co-author: Martin Orth

      Portions of this code (c) 2005 Martin Orth, m.orth@cfsolutions.de, feel free to contact me if there are further questions
      about this code, http://www.cfsolutions.de --->

      <!--- Co-author: Umer Farooq - Octadyne Systems
      Email: umer@octadyne.com
      Web: www.octadyne.com / www.autojini.com
      Portions of this code (c): Octadyne Systems. All Right Reserved,
      you are free to use this as long
      as this copyright notice stays in place.
      --->

      <!--- This code is licensed under the MIT license. You can review the terms here: http://www.opensource.org/licenses/mit-license.php
      --->

      <!--- The example code below works only with ColdFusion MX 7.0.
      With ColdFusion MX 7.0 the code should work fine.

      Steps to do:

      - register at developer.ebay.com
      - generate AppID, DevID and CertID (this identifies your application)
      - generate one seller and at least one buyer account for usage with the sandbox server
      - write down the user account details for later usage
      - use this new users and generate the auth tokens for them

      Notes:

      The eBay WSDL file is large(1.4 MB), so the first request takes from 1 - 10 minutes, because
      coldfusion generates a cache of class files for every method and property in the wsdl file.

      You can download the wsdl file and store it on a local webserver to to get it from there. This would
      lower network traffic and it is faster.
      --->

      <!--- set some vars --->
      <cfset endpoint="https://api.sandbox.ebay.com/wsapi">
      <cfset callName="geteBayOfficialTime">
      <cfset AppID="xxxxxxxxxxxx">
      <cfset DevID="xxxxxxxxx">
      <cfset CertID="xxxxxxxxxx">
      <cfset eBayAuthToken="xxxxxxxxxxxxxxxxx">
      <cfset version="419">
      <cfset routing="default">
      <cfset SiteID=77>
      <!--- 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://www.compralisto.com/programs/ebay/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.sandbox.ebay.com /wsapi?callname=#methodToCall#&siteid=#SiteID#&appid=#AppID#&version=#version#&Routing=#ro uting#");

      // 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>


      Thanks in advance

      Harry