当前页面: 开发资料首页 → Netbeans 专题 → Launching the eBay Java SDK API Calls Demo Sample Application from NetBeans 4.1
摘要: This is a follow up to the 23 Feb 2005 article, Using NetBeans to Develop with the eBay SDK for Java. As I continued to experiment with eBay's Java SDK, I found one sample application, the API Calls Demo, an invaluable resource for helping me learn the APIs. In this article, I show you how to create a NetBeans project that will will run and debug the API Calls Demo sample application
This article assumes you have already followed the steps for
setting up your environment outlined in Using
NetBeans to Develop with the eBay SDK for Java.
Select Build > Build Main Project,
press F11, or right-click the project node and choose Build Project
from the context menu.
Select Run > Run Main Project, press F6, or right-click the project node and choose Run Project from the context menu.
The project runs, however, you have to configure your account information every time you run the application, which can be quite tedious.
Let's fix that.
devId = <enter you developer ID> appId = <enter your application ID> certId = <enter your certificate ID> token = <enter your token> apiServerUrl = https://api.sandbox.ebay.com/wsapi epsServerUrl = http://msa-e1.ebay.com/ws/eBayISAPI.dll?EpsBasicApp
ApiCredential cred = new ApiCredential(); // Read properties file to load developer credentials Properties keys = new Properties(); try { keys.load(new FileInputStream("keys.properties")); } catch (IOException e) { System.out.println(e); } cred.seteBayToken(keys.getProperty("token")); ApiAccount ac = cred.getApiAccount(); ac.setDeveloper(keys.getProperty("devId")); ac.setApplication(keys.getProperty("appId")); ac.setCertificate(keys.getProperty("certId"));
this.apiContext.setApiServerUrl(keys.getProperty("apiServerUrl")); this.apiContext.setEpsServerUrl(keys.getProperty("epsServerUrl"));
Press F11 to build the application and F6 to run it. The API Account dialog is now properly configured. Select and API from the list box, such as GetSearchResults and press Run.
Note, if you are behind a corporate proxy and get a ConnectException, you can add the following two lines of code to the top of FrameDemo constructor:
System.setProperty("http.proxyHost", "<your proxy host>"); System.setProperty("http.proxyPort", "<your proxy port>");
<target name="debug" depends="compile" description="Debug Project"> <fail unless="netbeans.home">This target can only run inside the NetBeans IDE.</fail> <nbjpdastart name="Sample App" addressproperty="jpda.address" transport="dt_socket"> <classpath refid="project.class.path"/> <sourcepath path="${src}"/> </nbjpdastart> <java fork="true" classname="apicallsdemo.ApiCallsDemo"> <jvmarg value="-Xdebug"/> <jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/> <classpath refid="project.class.path"/> </java> </target>