How can I generate Java code stubs against Finding API WSDL using wsimport tool and make Finding API calls?
Summary
This sample uses wsimport tool that ships with JAX-WS to generate Java code stubs and demonstrates how to make Finding API calls.
Detailed Description
Software Requirements:
Java Downloads ((wsimport tool is available from jdk5 onwards))
Generate Java code stub using wsimport tool:
Once you have set up JAW-WS on your machine, go to the {JAX-WS install-dir}/bin directory where you will find the wsimport tool. Open command prompt, change the directory to {JAX-WS install-dir}/bin and enter the following command:
This will generate the required Java classes from the WSDL and you should see all the classes in the ./com/ebay/marketplace/search/v1/services directory.
String strBaseURL = "http://svcs.ebay.com/services/search/FindingService/v1"; FindingService service = new FindingService(); FindingServicePortType port = service.getFindingServiceSOAP12PortHttp();
BindingProvider bp = (BindingProvider) port; Map<String, Object> requestProperties = bp.getRequestContext(); Map<String, List<String>> httpHeaders = new HashMap<String, List<String>>(); //Set the headers httpHeaders.put("X-EBAY-SOA-MESSAGE-PROTOCOL", Collections.singletonList("SOAP12")); httpHeaders.put("X-EBAY-SOA-OPERATION-NAME", Collections.singletonList("findItemsAdvanced"));
//Edit the following line to insert your AppID to set the X-EBAY-SOA-SECURITY-APPNAMEcorrectly httpHeaders.put("X-EBAY-SOA-SECURITY-APPNAME", Collections.singletonList("YOUR_APP_ID_HERE"));