Advertisement

04.20.2008 at 02:12AM PDT, ID: 23337518
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.2

Able to run application Amazon Associate Web Service From from home but not from University using a proxy server

Asked by clivehcorner in SOAP, Apache Tomcat Application Server, Java Servlets

Tags: , , , , ,

I am developing an Amazon Associate web service (AAWS) P using their WSDL. For this I am using Tomcat version 6 and jdk 1.6 in Eclipse 3.3. The project is set up as a dynamic web project and uses Axis2.

I can run my application from home but not from within the University via a proxy server. AAWS  API uses SOAP previously I have used REST from within the university and used basic authentication, the REST app ran okay, see below the code for this (details changed for security)

*********************************************************************************************************************************
public class SimpleAuthenticator extends Authenticator {

    private String username;
    private String password;
                     
   public SimpleAuthenticator(String username, String password) {
      this.username = username;
      this.password = password;
   }
   
   public PasswordAuthentication getPasswordAuthentication() {
      return new PasswordAuthentication(username, password.toCharArray());
   }
}      

//below calls above:
try {
                  //Set up Authenticator
                  
                  System.setProperty( "proxySet", "true" );
                  System.setProperty("http.proxyHost", "proxyhost");
                  System.setProperty("http.proxyPort", "8080");
                  Authenticator.setDefault(new SimpleAuthenticator("usernamer",
                  "password"));
                  
            } catch (Exception e) {
                  e.printStackTrace();
            }


******************************************************************************************************************************
I The REST calls worked fine - however when using the Amazon API I get the error below


********************************************************************************************************************
Retrieving document at 'http://ecs.amazonaws.com/AWSECommerceService/UK/AWSECommerceService.wsdl'.
[INFO] Building AxisService from wsdl: http://ecs.amazonaws.com/AWSECommerceService/UK/AWSECommerceService.wsdl
[INFO] Unable to sendViaPost to url[http://soap.amazon.co.uk/onca/soap?Service=AWSECommerceService]
org.apache.axis2.AxisFault: Transport error: 501 Error: Not Implemented
      at org.apache.axis2.transport.http.HTTPSender.handleResponse(HTTPSender.java:298)
      at org.apache.axis2.transport.http.HTTPSender.sendViaPost(HTTPSender.java:192)
      at org.apache.axis2.transport.http.HTTPSender.send(HTTPSender.java:77)
      at org.apache.axis2.transport.http.CommonsHTTPTransportSender.writeMessageWithCommons(CommonsHTTPTransportSender.java:327)
      at org.apache.axis2.transport.http.CommonsHTTPTransportSender.invoke(CommonsHTTPTransportSender.java:206)
      at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:396)
      at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:374)
      at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:211)
      at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
      at org.apache.axis2.jaxws.core.controller.AxisInvocationController.execute(AxisInvocationController.java:570)
      at org.apache.axis2.jaxws.core.controller.AxisInvocationController.doInvoke(AxisInvocationController.java:110)
      at org.apache.axis2.jaxws.core.controller.InvocationController.invoke(InvocationController.java:105)
      at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invokeSEIMethod(JAXWSProxyHandler.java:271)
      at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invoke(JAXWSProxyHandler.java:141)
      at $Proxy10.itemSearch(Unknown Source)
      at servlet.MPCServlet.itemSearch(MPCServlet.java:293)
      at servlet.MPCServlet.doPost(MPCServlet.java:143)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
      at java.lang.Thread.run(Thread.java:595)
20-Apr-2008 09:25:53 org.apache.catalina.core.StandardWrapperValve invoke

*******************************************************************************************************************

I have also included the code for the main calling method in this itemsearch:


*******************************************************************************************************************
private void itemSearch(HttpServletRequest request,
                  HttpServletResponse response) {
      
            
                PrintWriter out = null;
            try {
                  out = response.getWriter();
            } catch (IOException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }
            
      
      
            String keyWord = request.getParameter("keyword");
            String url = request.getParameter("url");

            Vector<SearchItem> vect =  new Vector<SearchItem>();
            
            // Set the service:
            try{
            this.service = new AWSECommerceService();

            
      
            
            // Set the service port:
            AWSECommerceServicePortType port = service.getAWSECommerceServicePort();

            // Get the operation object:
            ItemSearchRequest itemRequest = new ItemSearchRequest();

            // Fill in the request object:
            itemRequest.setSearchIndex(url);
            itemRequest.setKeywords(keyWord);
            
            
            ItemSearch ItemElement = new ItemSearch();
            ItemElement.setAWSAccessKeyId("AccesskeyID");
            ItemElement.getRequest().add(itemRequest);

            ItemElement.setAssociateTag("AssociateTag");
          
                        
            // Call the Web service operation and store the response
            // in the response object:
            ItemSearchResponse amazonResponse = port
                        .itemSearch(ItemElement);
            
            OperationRequest     operationRequest = amazonResponse.getOperationRequest();
            
            

            if (operationRequest != null) {
                  BigInteger totalpages = null;

                  for (Items itemList : amazonResponse.getItems()) {
                        Request requestElement = itemList.getRequest();
                        if (requestElement != null) {
                              totalpages = itemList.getTotalPages();
                        }
                        

                        for (Item item : itemList.getItem()) {
                              out.println("Product Name: "
                                          + item.getItemAttributes().getTitle() + " "  +
                                          item.getASIN());
                              String title = item.getItemAttributes().getTitle();
                              Price price = item.getItemAttributes().getListPrice();
                              //String listPrice = price.getFormattedPrice();
                              String listPrice = "";
                              String manufacturer = item.getItemAttributes().getManufacturer();
                              SearchItem searchItem = new SearchItem(title,manufacturer,listPrice);
                        
                              vect.add(searchItem);
                              

                        }

                  }

                  
                  
            }
            
            
        
            
      }
      finally{
            
      }
      
      request.setAttribute("stuff", vect);
      requestDespatch(request, response, "itemsearchresult.jsp");
      
      
      }



*****************************************************************************************************************


I have tried numerous solutions to this problem.

1st solution - adding the following to axis.xml within the transport sender section:

            
                   <ProxyHost>wwwcache.csd.abdn.ac.uk</ProxyHost>
                      <ProxyPort>8080</ProxyPort>
                      <ProxyUser>ccorner</ProxyUser>
                      <ProxyPassword>WYHAFApa</ProxyPassword>

2nd solution

Attempted to authenticate and set up the proxy properties in the code

            Options options = new Options();
      
            HttpTransportProperties.ProxyProperties pp = new HttpTransportProperties.ProxyProperties();
            
             pp.setProxyName("proxyname");
             pp.setProxyPort(8080);
             pp.setUserName("username");
             pp.setPassWord("password");
            
            
            HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
            
            auth.setPassword("password");
            auth.setUsername("username");
            auth.setHost("proxyname");
            auth.setPort(8080);

            
             options.setProperty(HTTPConstants.PROXY, pp);
             options.setProperty(HTTPConstants.AUTHENTICATE,auth );

After this I tried commenting out the simple authenticator code and just using solution 2

Can you help in this please.

Thanks

Clive Corner
Start Free Trial
[+][-]04.20.2008 at 06:17AM PDT, ID: 21395937

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.20.2008 at 08:13AM PDT, ID: 21396318

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: SOAP, Apache Tomcat Application Server, Java Servlets
Tags: J2EE, Amazon Associate Web Service, Version 2008-04-07, Using a proxy server, J2EE, [INFO] Unable to sendViaPost to url[http://soap.amazon.co.uk/onca/soap?Service=AWSECommerceService]
Sign Up Now!
Solution Provided By: clivehcorner
Participating Experts: 1
Solution Grade: A
 
 
[+][-]04.21.2008 at 07:57AM PDT, ID: 21402531

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.23.2008 at 09:16AM PDT, ID: 21422349

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628