Results 1 to 4 of 4
  1. #1
    SnakeDoc is offline Senior Member
    Join Date
    Apr 2012
    Posts
    129
    Rep Power
    0

    Exclamation Help working with Amazon MWS API using Java Client Libraries

    Hello All!

    I have been tasked with figuring out the Amazon MWS (Marketplace Web Service) API and how to use it with the provided Java Client Libraries. I am learning Java, but am not a pro (yet ;-p)!

    The directions provided by Amazon are... terrible to say the least. They provide source code files that they claim you can use "almost right out of the box" after configuring some variables that hold your API credentials.

    My problem is, it's not "working out of the box"... and I"m struggling to make any headway... and getting demotivated as I go. :(

    Can someone please provide some direction on how I should go about trying to make this work? I am attempting to do a very basic task and talk to the API to check its status (if its online or not). My thoughts are once I get that working, I can build on that knowledge and then do more advanced things such as process orders, etc.

    So far I have downloaded the Java Client Libraries that Amazon has provided, unpacked them into a directory. I have configured the SellersSampleConfig.java file, but when I go to compile it using javac or any other program (like Groovy or Eclipse), I get errors related to not being able to resolve class com.amazonservices.mws.sellers.MarketplaceWebServi ceSellersConfig .

    The com.amazonservices.mws.sellers.MarketplaceWebServi ceSellersConfig source file (.java) is located under /com/amazonservices/mws/sellers/

    So i tried to compile the MarketplaceWebServiceSellersConfig.java into a class file... whcih worked. so now i have a MarketplaceWebServiceSellersConfig.class file in the same directory for a full name of: com.amazonservices.mws.sellers.MarketplaceWebServi ceSellersConfig

    However, when I go back to compile my original file SellersSampleConfig.java, I still get errors staying it cannot resolve the class... as if its not seeing it.

    What am I doing wrong? Can someone please provide a direction for me? Thank you so much in advance!

    Resources:

    https://developer.amazonservices.com/index.html (MWS home page)

    https://images-na.ssl-images-amazon....134269961_.pdf (developers guide -- not much in here thats helpful)

    https://developer.amazonservices.com...0701/java.html (Java Client Library home page)

    https://images-na.ssl-images-amazon....138503354_.zip (Java Client Library Download)

  2. #2
    SnakeDoc is offline Senior Member
    Join Date
    Apr 2012
    Posts
    129
    Rep Power
    0

    Default Re: Help working with Amazon MWS API using Java Client Libraries

    OK just posting an update -- I have successfully compiled the SellersSampleConfig.java file into a .class using javac. My problem (due to my newbness) was I did not include the -cp argument when compiling... so i belive this was my problem with not being able to resolve the other files.

    Ok, so now I understand that I dont need to necessarily compile all the files int he Java Client Library to get them to work, since compliling some with the -cp argument pulls from the other soruce files.

    Now I am attemping to make use of the GetServiceStatusSample.java source file to check the API status (online or not). I threw it into Eclipse to see what it said and get errors when I attempt to run it:

    Exception in thread "main" java.lang.Error: Unresolved compilation problems:
    The import org.apache cannot be resolved
    The import org.apache cannot be resolved
    The import org.apache cannot be resolved
    The import org.apache cannot be resolved
    The import org.apache cannot be resolved
    The import org.apache cannot be resolved
    The import org.apache cannot be resolved
    The import org.apache cannot be resolved
    The import org.apache cannot be resolved
    The import org.apache cannot be resolved
    The import org.apache cannot be resolved
    The import org.apache cannot be resolved
    The import org.apache cannot be resolved
    The import org.apache cannot be resolved
    The import org.apache cannot be resolved
    The import org.apache cannot be resolved
    The import org.apache cannot be resolved
    The import org.apache cannot be resolved
    The import org.apache cannot be resolved
    Log cannot be resolved to a type
    LogFactory cannot be resolved
    HttpClient cannot be resolved to a type
    HttpClient cannot be resolved to a type
    The method configureHttpClient(String, String) from the type MarketplaceWebServiceSellersClient refers to the missing type HttpClient
    HttpClient cannot be resolved to a type
    HttpClientParams cannot be resolved to a type
    HttpClientParams cannot be resolved to a type
    HttpMethodParams cannot be resolved to a variable
    HttpClientParams cannot be resolved to a variable
    HttpMethodRetryHandler cannot be resolved to a type
    HttpMethod cannot be resolved to a type
    Log cannot be resolved to a type
    Log cannot be resolved to a type
    Incompatible conditional operand types IOException and NoHttpResponseException
    NoHttpResponseException cannot be resolved to a type
    Log cannot be resolved to a type
    Log cannot be resolved to a type
    Log cannot be resolved to a type
    Log cannot be resolved to a type
    HostConfiguration cannot be resolved to a type
    HostConfiguration cannot be resolved to a type
    HttpConnectionManagerParams cannot be resolved to a type
    HttpConnectionManagerParams cannot be resolved to a type
    MultiThreadedHttpConnectionManager cannot be resolved to a type
    MultiThreadedHttpConnectionManager cannot be resolved to a type
    HttpClient cannot be resolved to a type
    HttpClient cannot be resolved to a type
    Log cannot be resolved to a type
    HttpClient cannot be resolved to a type
    AuthScope cannot be resolved to a type
    UsernamePasswordCredentials cannot be resolved to a type
    HttpClient cannot be resolved to a type
    HttpClient cannot be resolved to a type
    PostMethod cannot be resolved to a type
    PostMethod cannot be resolved to a type
    Log cannot be resolved to a type
    Log cannot be resolved to a type
    Log cannot be resolved to a type
    Log cannot be resolved to a type
    Log cannot be resolved to a type
    HttpClient cannot be resolved to a type
    HttpStatus cannot be resolved to a variable
    Log cannot be resolved to a type
    Log cannot be resolved to a type
    Log cannot be resolved to a type
    Log cannot be resolved to a type
    HttpStatus cannot be resolved to a variable
    Log cannot be resolved to a type
    Log cannot be resolved to a type
    HttpStatus cannot be resolved to a variable
    Log cannot be resolved to a type
    Log cannot be resolved to a type
    Log cannot be resolved to a type
    Log cannot be resolved to a type
    Log cannot be resolved to a type
    Log cannot be resolved to a type
    Log cannot be resolved to a type
    PostMethod cannot be resolved to a type
    Log cannot be resolved to a type
    Log cannot be resolved to a type
    Log cannot be resolved to a type
    Log cannot be resolved to a type
    Log cannot be resolved to a type
    Base64 cannot be resolved
    HttpsURL cannot be resolved to a type
    URIException cannot be resolved to a type
    HttpURL cannot be resolved to a type
    HttpsURL cannot be resolved to a type
    HttpURL cannot be resolved to a type
    URIException cannot be resolved to a type
    HttpsURL cannot be resolved to a variable
    HttpURL cannot be resolved to a variable

    at com.amazonservices.mws.sellers.MarketplaceWebServi ceSellersClient.<init>(MarketplaceWebServiceSeller sClient.java:37)
    at com.amazonservices.mws.sellers.samples.GetServiceS tatusSample.main(GetServiceStatusSample.java:69)



    My code is as follows:

    /************************************************** *****************************
    * Copyright 2009 Amazon Services.
    * Licensed under the Apache License, Version 2.0 (the "License");
    *
    * You may not use this file except in compliance with the License.
    * You may obtain a copy of the License at: Apache License
    * This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
    * CONDITIONS OF ANY KIND, either express or implied. See the License for the
    * specific language governing permissions and limitations under the License.
    * ************************************************** ***************************
    *
    * Marketplace Web Service Sellers Java Library
    * API Version: 2011-07-01
    * Generated: Fri Jun 24 20:08:04 GMT 2011
    *
    */



    package com.amazonservices.mws.sellers.samples;

    import java.util.List;
    import java.util.ArrayList;

    import com.amazonservices.mws.sellers.*;
    import com.amazonservices.mws.sellers.mock.MarketplaceWeb ServiceSellersMock;
    import com.amazonservices.mws.sellers.model.*;

    /**
    *
    * Get Service Status Samples
    *
    *
    */
    @SuppressWarnings("unused")
    public class GetServiceStatusSample {

    /**
    * Just add few required parameters, and try the service
    * Get Service Status functionality
    *
    * @param args unused
    */
    public static void main(String... args) {

    /*
    * Add required parameters in SellersSampleConfig.java before trying out
    * this sample.
    */

    /************************************************** **********************
    * Uncomment to try out Mock Service that simulates Marketplace Web
    * Service Sellers responses without calling Marketplace Web Service
    * Sellers service.
    *
    * Responses are loaded from local XML files. You can tweak XML files to
    * experiment with various outputs during development
    *
    * XML files available under com/amazonservices/mws/mock tree
    *
    ************************************************** *********************/
    //MarketplaceWebServiceSellers service = new MarketplaceWebServiceSellersMock();

    /************************************************** **********************
    * Instantiate Http Client Implementation of Marketplace Web Service
    * Sellers API
    ************************************************** **********************/

    MarketplaceWebServiceSellers service = new MarketplaceWebServiceSellersClient(
    SellersSampleConfig.accessKeyId,
    SellersSampleConfig.secretAccessKey,
    SellersSampleConfig.applicationName,
    SellersSampleConfig.applicationVersion,
    SellersSampleConfig.config);

    /************************************************** **********************
    * Setup request parameters and uncomment invoke to try out sample for
    * Get Service Status
    ************************************************** *********************/
    GetServiceStatusRequest request = new GetServiceStatusRequest();
    // @TODO: set request parameters here
    request.setSellerId(SellersSampleConfig.sellerId);

    invokeGetServiceStatus(service, request);

    }




    /**
    * Get Service Status request sample
    * Returns the service status of a particular MWS API section. The operation
    * takes no input. All API sections within the API are required to implement this operation.
    *
    * @param service instance of MarketplaceWebServiceSellers service
    * @param request Action to invoke
    */
    public static void invokeGetServiceStatus(MarketplaceWebServiceSeller s service, GetServiceStatusRequest request) {
    try {

    GetServiceStatusResponse response = service.getServiceStatus(request);


    System.out.println ("GetServiceStatus Action Response");
    System.out.println ("================================================ =============================");
    System.out.println ();

    System.out.println(" GetServiceStatusResponse");
    System.out.println();
    if (response.isSetGetServiceStatusResult()) {
    System.out.println(" GetServiceStatusResult");
    System.out.println();
    GetServiceStatusResult getServiceStatusResult = response.getGetServiceStatusResult();
    if (getServiceStatusResult.isSetStatus()) {
    System.out.println(" Status");
    System.out.println();
    System.out.println(" " + getServiceStatusResult.getStatus().value());
    System.out.println();
    }
    if (getServiceStatusResult.isSetTimestamp()) {
    System.out.println(" Timestamp");
    System.out.println();
    System.out.println(" " + getServiceStatusResult.getTimestamp());
    System.out.println();
    }
    if (getServiceStatusResult.isSetMessageId()) {
    System.out.println(" MessageId");
    System.out.println();
    System.out.println(" " + getServiceStatusResult.getMessageId());
    System.out.println();
    }
    if (getServiceStatusResult.isSetMessages()) {
    System.out.println(" Messages");
    System.out.println();
    MessageList messages = getServiceStatusResult.getMessages();
    java.util.List<Message> messageList = messages.getMessage();
    for (Message message : messageList) {
    System.out.println(" Message");
    System.out.println();
    if (message.isSetLocale()) {
    System.out.println(" Locale");
    System.out.println();
    System.out.println(" " + message.getLocale());
    System.out.println();
    }
    if (message.isSetText()) {
    System.out.println(" Text");
    System.out.println();
    System.out.println(" " + message.getText());
    System.out.println();
    }
    }
    }
    }
    if (response.isSetResponseMetadata()) {
    System.out.println(" ResponseMetadata");
    System.out.println();
    ResponseMetadata responseMetadata = response.getResponseMetadata();
    if (responseMetadata.isSetRequestId()) {
    System.out.println(" RequestId");
    System.out.println();
    System.out.println(" " + responseMetadata.getRequestId());
    System.out.println();
    }
    }
    System.out.println();


    } catch (MarketplaceWebServiceSellersException ex) {

    System.out.println("Caught Exception: " + ex.getMessage());
    System.out.println("Response Status Code: " + ex.getStatusCode());
    System.out.println("Error Code: " + ex.getErrorCode());
    System.out.println("Error Type: " + ex.getErrorType());
    System.out.println("Request ID: " + ex.getRequestId());
    System.out.print("XML: " + ex.getXML());
    }
    }

    }
    Last edited by SnakeDoc; 04-13-2012 at 12:51 AM.

  3. #3
    Bacon is offline Member
    Join Date
    Feb 2013
    Posts
    1
    Rep Power
    0

    Default Re: Help working with Amazon MWS API using Java Client Libraries

    SnakeDoc,

    I too am quite new to Java and am trying to understand Amazon MWS API and their client libraries. I am afraid that I cannot provide any help with your current query, but wondered if you might like to get in email contact to discuss Java/Amazon issues? I find the Amazon client libraries to be confusing beyond imagination and haven't even got I sample request to run yet. Instead, I am trying to write a bespoke application from scratch, so that I can better understand how my application works. As I am learning java on my own, I am looking for someone to bounce ideas off etc. I hope that that sounds interesting to you!

    Andrew
    address removed
    Last edited by DarrylBurke; 02-14-2013 at 04:19 PM. Reason: Removed email address

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,193
    Rep Power
    19

    Default Re: Help working with Amazon MWS API using Java Client Libraries

    This forum is for discussions, not for taking discussions where they are of no benefit to the community.

    Also, don't resurrect long-dead threads.

    db

    THREAD CLOSED
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. TCP/IP client not working properly
    By Chrillz in forum Networking
    Replies: 2
    Last Post: 07-20-2011, 07:39 PM
  2. Simple TCP Client/Server not working?!?!?!
    By FiniteRed in forum Networking
    Replies: 1
    Last Post: 07-15-2011, 03:23 PM
  3. client not working
    By hit here in forum New To Java
    Replies: 2
    Last Post: 08-10-2008, 01:00 AM
  4. Replies: 8
    Last Post: 05-28-2008, 07:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •