Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

WebServices The code given below shows portions of a Java Servlet that calls a S

ID: 3715001 • Letter: W

Question

WebServices

The code given below shows portions of a Java Servlet that calls a SOAP-based Web Service named “create” to create a new customer order. However, there are some essential statements missing from this

Servlet class that are needed to make this process to work. The missing code includes: one annotation statement, one declaration statement, and a “create” method that will call the Web service client. (See code comments.) Write the missing Java code in this Servlet.

public class ExamServlet extends HttpServlet

{

    // Missing Web service annotation statement needed here

    // Missing Web service declaration statement needed here

     protected void processRequest(HttpServletRequest request,                                    HttpServletResponse response)                                   throws ServletException, IOException     {

      .

      .

      .

      Orders order = new Orders();       .

     .       .

      create(order);   // This calls the local create method which                        // in turn calls the Web service operation       .

      .

      .

Explanation / Answer

//creating annotation

import java.lang.annotation.*;  

import java.lang.reflect.*;  

@Retention(RetentionPolicy.RUNTIME)  

@Target(ElementType.METHOD)  

@interface MyAnnotation{ //declaration for CUSTOM ANNOTATION MyAnnotation

//Body of the annotation method

}  

//applying annotation

public class ExamServlet extends HttpServlet

{

@MyAnnotation() //can pass parameters to annotation during call if required for the body of annotation

protected void processRequest(HttpServletRequest request,HttpServletResponse response)                                   throws ServletException, IOException     {

Orders order = new Orders();

create(order);

public void create(Orders obj) //can change the access specifier as per requirement

{

String url= "type-the-URL-of-destination"; //DO CHANGE
String action= "type-the-url-for-computation"; //DO CHANGE

callSoapWebService(url,action);

}

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote