Irshad--

You need to include the http-client jar in your classpath.  XFire needs
this to actually make the http requests to the service.

You should be able to find this in the xfire distribution in the lib
directory:
commons-httpclient-3.0.jar

After you do this, if you run into other NoClassDefFoundErrors, it's
likely that you're missing other dependencies too-- all of which you
should be able to find in the xfire dist's lib directory.

-Chris

-----Original Message-----
From: Irshad Buchh [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 09, 2007 9:04 AM
To: [email protected]
Subject: [xfire-user] XFire with amazon webservices.


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:1
31)
        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.ItemLookupRespons
e;
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.ItemSearchRespons
e;
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#a823
8193
Sent from the XFire - User mailing list archive at Nabble.com.


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

    http://xircles.codehaus.org/manage_email


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

    http://xircles.codehaus.org/manage_email

Reply via email to