package de.tu_dresden.diplom.richter_mirko_mat2628335.soap;

import de.tu_dresden.diplom.richter_mirko_mat2628335.common.info.account.IFAccountInfo;
import de.tu_dresden.diplom.richter_mirko_mat2628335.common.Constants;
import de.tu_dresden.diplom.richter_mirko_mat2628335.Configuration;
import org.apache.axis.client.Service;
import org.apache.axis.client.Call;

import javax.xml.namespace.QName;
import javax.xml.rpc.ServiceException;
import java.net.URL;
import java.net.MalformedURLException;
import java.rmi.RemoteException;

/**
 * 
 */
public class HLPInfoPeer {

   private static final Configuration conf = new Configuration(Configuration.APPLICATION_SOAP_UNIT_TEST);

   public static IFAccountInfo getAccountInfo(){
      IFAccountInfo result = null;
      try {
         String endPoint = Constants.SERVICE_ENDPOINT_WITNESS_INFORMATION;
         System.setProperty("axis.ClientConfigFile", conf.getModuleUsageCounterHome() + "/WEB-INF/requestInfo_config.wsdd");
         Service service = new Service();
         //QName qnameRequest = new QName("http://diplom.compago.de", "ContextCreationRequest");
         QName qnameResponse = new QName("http://diplom.compago.de", "IFAccountInfo");
         Call call = (Call) service.createCall();
         call.setTargetEndpointAddress(new URL(endPoint));
         call.setOperationName("getAccountInfo");
         //call.addParameter("request", qnameRequest, ParameterMode.IN);
         call.setReturnType(qnameResponse);
         result = (IFAccountInfo) call.invoke(new Object[]{});
      } catch (ServiceException e) {
         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
      } catch (MalformedURLException e) {
         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
      } catch (RemoteException e) {
         e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
      }
      return result;
   }

}
