package com.navercorp.pinpoint.testapp.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.navercorp.pinpoint.testapp.util.Description;

import sample.axisversion.Version;
import sample.axisversion.VersionPortType;

/**
 * @author koo.taejin
 */
@Controller
public class SimpleController {

    @RequestMapping("/getCurrentTimestamp")
    @ResponseBody
    @Description("Returns the server's current timestamp.")
    public Map<String, Object> getCurrentTimestamp() {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("getCurrentTimestamp", System.currentTimeMillis());

        return map;
    }

    @RequestMapping("/sleep3")
    @ResponseBody
    @Description("Call that takes 3 seconds to complete.")
    public Map<String, Object> sleep3() throws InterruptedException {
        Thread.sleep(3000);

        Map<String, Object> map = new HashMap<String, Object>();
        map.put("message", "ok");

        return map;
    }

    @RequestMapping("/sleep5")
    @ResponseBody
    @Description("Call that takes 5 seconds to complete")
    public Map<String, Object> sleep5() throws InterruptedException {
        Thread.sleep(5000);

        Map<String, Object> map = new HashMap<String, Object>();
        map.put("message", "ok");

        return map;
    }

    @RequestMapping("/sleep7")
    @ResponseBody
    @Description("Call that takes 7 seconds to complete")
    public Map<String, Object> sleep7() throws InterruptedException {
        Thread.sleep(7000);

        Map<String, Object> map = new HashMap<String, Object>();
        map.put("message", "ok");

        return map;
    }
    
    @RequestMapping("/webservice")
    @ResponseBody
    @Description("Call a webservice")
    public Map<String, Object> webservice() throws InterruptedException {
        Map<String, Object> map = new HashMap<String, Object>();
        String response = "ok";
        
//        try {
//            RPCServiceClient serviceClient = new RPCServiceClient();
//
//            Options options = serviceClient.getOptions();
//
//            EndpointReference targetEPR = new EndpointReference(
//                    "http://52.66.130.230:8080/axis2/services/listServices");
//            options.setTo(targetEPR);
//            options.setAction("urn:getVersion");
//
//            QName opGetVersion = 
//                new QName("http://ws.axis2.apache.org", "getVersion", "req");
//            
//            OMElement result = serviceClient.invokeBlocking(opGetVersion, new Object[]{null});
//            
//            response = result.getFirstElement().getText();
//            
//        } catch (AxisFault e) {
//            // TODO Auto-generated catch block
//            e.printStackTrace();
//        }
        
        try {
            Version service = new Version();
            System.out.println("Retrieving the port from the following service: " + service);
            VersionPortType port = service.getVersionHttpSoap11Endpoint();
            System.out.println("Invoking the sayHello operation on the port.");

            response = port.getVersion();
            System.out.println(response);
        } catch (Exception e) {
            e.printStackTrace();
        }
        
        map.put("message", response);
        return map;
    }

}

@@ -330,87 +330,8 @@
 n;%0A%0A
-import sample.axisversion.Version;%0Aimport sample.axisversion.VersionPortType;%0A%0A
 /**%0A
@@ -1741,1677 +1741,8 @@
    %7D
-%0A    %0A    @RequestMapping(%22/webservice%22)%0A    @ResponseBody%0A    @Description(%22Call a webservice%22)%0A    public Map%3CString, Object%3E webservice() throws InterruptedException %7B%0A        Map%3CString, Object%3E map = new HashMap%3CString, Object%3E();%0A        String response = %22ok%22;%0A        %0A//        try %7B%0A//            RPCServiceClient serviceClient = new RPCServiceClient();%0A//%0A//            Options options = serviceClient.getOptions();%0A//%0A//            EndpointReference targetEPR = new EndpointReference(%0A//                    %22http://52.66.130.230:8080/axis2/services/listServices%22);%0A//            options.setTo(targetEPR);%0A//            options.setAction(%22urn:getVersion%22);%0A//%0A//            QName opGetVersion = %0A//                new QName(%22http://ws.axis2.apache.org%22, %22getVersion%22, %22req%22);%0A//            %0A//            OMElement result = serviceClient.invokeBlocking(opGetVersion, new Object%5B%5D%7Bnull%7D);%0A//            %0A//            response = result.getFirstElement().getText();%0A//            %0A//        %7D catch (AxisFault e) %7B%0A//            // TODO Auto-generated catch block%0A//            e.printStackTrace();%0A//        %7D%0A        %0A        try %7B%0A            Version service = new Version();%0A            System.out.println(%22Retrieving the port from the following service: %22 + service);%0A            VersionPortType port = service.getVersionHttpSoap11Endpoint();%0A            System.out.println(%22Invoking the sayHello operation on the port.%22);%0A%0A            response = port.getVersion();%0A            System.out.println(response);%0A        %7D catch (Exception e) %7B%0A            e.printStackTrace();%0A        %7D%0A        %0A        map.put(%22message%22, response);%0A        return map;%0A    %7D
 %0A%0A%7D%0A

removed axis2 test app