Hi
As i remember Eclipse plugin doesn't copy all jars required by client
code, so you must add them manually to your classpath. You can build
any of the app from example directory ( e.g. book ) and see what jars
are needed beside of these in your classpath ( like commons-httpclient
)

On 1/9/07, Irshad Buchh <[EMAIL PROTECTED]> wrote:

Hi,

I just used eclipse xfire plugin to generate java code from amazon ec
webservice. The code generation was just fine. Now I tried to create a
client class with the following code. When I run this class I get the
following errors. Where is the problem?



Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/commons/httpclient/methods/RequestEntity
        at java.lang.Class.getDeclaredConstructors0(Native Method)
        at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
        at java.lang.Class.getConstructor0(Unknown Source)
        at java.lang.Class.getConstructor(Unknown Source)
        at
org.codehaus.xfire.transport.http.HttpChannel.sendViaClient(HttpChannel.java:108)
        at 
org.codehaus.xfire.transport.http.HttpChannel.send(HttpChannel.java:48)
        at
org.codehaus.xfire.handler.OutMessageSender.invoke(OutMessageSender.java:26)
        at
org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:131)
        at org.codehaus.xfire.client.Invocation.invoke(Invocation.java:75)
        at org.codehaus.xfire.client.Client.invoke(Client.java:335)
        at 
org.codehaus.xfire.client.XFireProxy.handleRequest(XFireProxy.java:77)
        at org.codehaus.xfire.client.XFireProxy.invoke(XFireProxy.java:57)
        at $Proxy10.itemSearch(Unknown Source)
        at edu.ksu.sa.ws.WebServicesClient.main(WebServicesClient.java:90)

CLIENT CLASS:


mport java.net.MalformedURLException;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codehaus.xfire.XFire;
import org.codehaus.xfire.XFireFactory;
import org.codehaus.xfire.client.XFireProxyFactory;
import org.codehaus.xfire.jaxb2.JaxbServiceFactory;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.service.binding.ObjectServiceFactory;

import com.amazon.webservices.awsecommerceservice._2006_11_14.Help;
import com.amazon.webservices.awsecommerceservice._2006_11_14.HelpResponse;
import com.amazon.webservices.awsecommerceservice._2006_11_14.Item;
import com.amazon.webservices.awsecommerceservice._2006_11_14.ItemLookup;
import
com.amazon.webservices.awsecommerceservice._2006_11_14.ItemLookupRequest;
import
com.amazon.webservices.awsecommerceservice._2006_11_14.ItemLookupResponse;
import com.amazon.webservices.awsecommerceservice._2006_11_14.ItemSearch;
import
com.amazon.webservices.awsecommerceservice._2006_11_14.ItemSearchRequest;
import
com.amazon.webservices.awsecommerceservice._2006_11_14.ItemSearchResponse;
import com.amazon.webservices.awsecommerceservice._2006_11_14.Items;
import com.amazon.webservices.awsecommerceservice._2006_11_14.Request;

/**
 * @author irshad
 *
 */
public class WebServicesClient {
protected final static Log log =
LogFactory.getLog(WebServicesClient.class.getName());
        /**
         * @param args
         */
        public static void main(String[] args) {
                // TODO Auto-generated method stub


            Service serviceModel = new
ObjectServiceFactory().create(edu.ksu.sa.ws.AWSECommerceServicePortType.class);
            log.debug("callSoapServiceLocal(): got service model." );

            //Create a proxy for the deployed service
            XFire xfire = XFireFactory.newInstance().getXFire();
            XFireProxyFactory factory = new XFireProxyFactory(xfire);

            String serviceUrl =
"http://webservices.amazon.com/AWSECommerceService";;

            edu.ksu.sa.ws.AWSECommerceServicePortType client = null;
            try {
                client = (edu.ksu.sa.ws.AWSECommerceServicePortType)
factory.create(serviceModel, serviceUrl);
            } catch (MalformedURLException e) {
                log.error("WsClient.callWebService(): EXCEPTION: " + 
e.toString());
            }

            //Invoke the service
            String serviceResponse = "";


                ItemSearchRequest request = new ItemSearchRequest();

                request.setSearchIndex("Books");
                request.setPower("title");
                //request.settrsetResponseGroup = new String[] { "Small" };
                request.setSort("salesrank");

                ItemSearchRequest[] requests = new ItemSearchRequest[] { 
request };

                ItemSearch itemSearch = new ItemSearch();
                itemSearch.setSubscriptionId("0525E2PQ81DD7ZTWTK82");
                itemSearch.setShared(request);

                try
                {
                ItemSearchResponse response = client.itemSearch(itemSearch);
                Items info = response.getItems().get(0);
                List items = info.getItem();

                for (int i = 0; i < items.size(); i++)
                {
                Item item =(Item) items.get(i);
                System.out.println(item.getASIN());
                }
                }
                catch (Exception ex)
                {
                ex.printStackTrace();
                }

//              Create a metadata of the service

        }



        }

--
View this message in context: 
http://www.nabble.com/XFire-with-amazon-webservices.-tf2946121.html#a8238193
Sent from the XFire - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email




--
-----
When one of our products stops working, we'll blame another vendor
within 24 hours.

---------------------------------------------------------------------
To unsubscribe from this list please visit:

   http://xircles.codehaus.org/manage_email

Reply via email to