/**
   * @param filestoreURLString the externally reachable URL of the WebDAV filestore, e.g.
   *     "http://localhost:9000/filestore"
   */
  public FileStoreServiceClient(URI filestoreURLString) throws SOAPException {

    WebServiceTemplate webServiceTemplate = createWebServiceTemplate(filestoreURLString);

    try {
      this.baseURI = new URI(webServiceTemplate.getDefaultUri());
    } catch (URISyntaxException e) {
      throw new Error("Bad hardcoded URI", e);
    }

    this.webServiceTemplate = webServiceTemplate;
  }
Esempio n. 2
0
  // send to an explicit URI
  public void customSendAndReceive() throws SOAPException {
    MessageFactory messageFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
    SaajSoapMessageFactory newSoapMessageFactory = new SaajSoapMessageFactory(messageFactory);
    webServiceTemplate.setMessageFactory(newSoapMessageFactory);

    StreamSource source = new StreamSource(new StringReader(REQUEST_PERIODIC));
    StreamResult result = new StreamResult(System.out);
    webServiceTemplate.sendSourceAndReceiveToResult(
        URL_PERIODIC,
        source,
        new SoapActionCallback("http://www.webserviceX.NET/GetAtomicWeight"),
        result);
  }
  @Bean
  public WebServiceTemplate webServiceTemplate(Jaxb2Marshaller marshaller) {
    WebServiceTemplate webServiceTemplate = new WebServiceTemplate();
    webServiceTemplate.setMarshaller(marshaller);
    webServiceTemplate.setUnmarshaller(marshaller);
    webServiceTemplate.setDefaultUri("http://localhost:10308/0308-ws-objectfactory-service");

    HttpComponentsMessageSender messageSender = new HttpComponentsMessageSender();
    messageSender.setConnectionTimeout(100);
    messageSender.setMaxTotalConnections(10);
    webServiceTemplate.setMessageSender(messageSender);
    return webServiceTemplate;
  }
Esempio n. 4
0
 @Override
 public String sayHello(String name) {
   SayHelloRequest request = WS_CLIENT_FACTORY.createSayHelloRequest();
   request.setName(name);
   SayHelloResponse response = (SayHelloResponse) wsTemplate.marshalSendAndReceive(request);
   return response.getName();
 }
 @Test
 public void testEcho() {
   QueryOrderRequest request = new QueryOrderRequest();
   QueryOrderResponse response =
       (QueryOrderResponse) webServiceTemplate.marshalSendAndReceive(echoUrl, request);
   System.out.println(ToStringBuilder.reflectionToString(response));
 }
Esempio n. 6
0
 @Override
 public List<UserGen> getUsersByName(String name) {
   GetUsersByNameRequest request = WS_CLIENT_FACTORY.createGetUsersByNameRequest();
   request.setName(name);
   GetUsersByNameResponse response =
       (GetUsersByNameResponse) wsTemplate.marshalSendAndReceive(request);
   return response.getUserGen();
 }
  public int getBalance() throws LogonException {
    if (!session.alreadyLoggedOn())
      throw new LogonException("Not Logged On; Session does not exist");

    GetBalanceRequest getBalanceRequest = new GetBalanceRequest();
    getBalanceRequest.setSessionId(session.getSessionId());

    return ((GetBalanceResponse) wsTemplate.marshalSendAndReceive(getBalanceRequest)).getBalance();
  }
 public String getEndpointUri() {
   if (endpointMappingKey != null) {
     // only for consumers, use lookup key as endpoint uri/key
     return encode(endpointMappingKey.getLookupKey());
   } else if (webServiceTemplate != null) {
     return webServiceTemplate.getDefaultUri();
   }
   return null;
 }
  /**
   * Default Constructor.
   *
   * @param webServiceTemplate the webservice template
   */
  public FileStoreServiceClient(WebServiceTemplate webServiceTemplate) {
    try {
      this.baseURI = new URI(webServiceTemplate.getDefaultUri());
    } catch (URISyntaxException e) {
      throw new Error("Bad hardcoded URI", e);
    }

    this.webServiceTemplate = webServiceTemplate;
  }
  public void submitQuest(int questID) throws LogonException {
    if (!session.alreadyLoggedOn())
      throw new LogonException("Not Logged On; Session does not exist");

    SubmitQuestRequest submitQuestRequest = new SubmitQuestRequest();
    submitQuestRequest.setSessionId(session.getSessionId());
    submitQuestRequest.setQuestID(questID);

    wsTemplate.marshalSendAndReceive(submitQuestRequest);
  }
Esempio n. 11
0
  public Double getConversionRate(Currency fromCurrency, Currency toCurrency) {
    ConversionRate conversionRate = new ObjectFactory().createConversionRate();
    conversionRate.setFromCurrency(fromCurrency);
    conversionRate.setToCurrency(toCurrency);

    ConversionRateResponse response =
        (ConversionRateResponse) webServiceTemplate.marshalSendAndReceive(conversionRate);

    return response.getConversionRateResult();
  }
  private static WebServiceTemplate createWebServiceTemplate(URI defaultURI) throws SOAPException {

    SaajSoapMessageFactory messageFactory =
        new SaajSoapMessageFactory(MessageFactory.newInstance());
    messageFactory.setSoapVersion(SOAP_11);

    HttpComponentsMessageSender httpSender = new HttpComponentsMessageSender();
    httpSender.setConnectionTimeout(1200000);
    httpSender.setReadTimeout(1200000);

    Jaxb2Marshaller serviceMarshaller = new Jaxb2Marshaller();
    serviceMarshaller.setContextPath("org.apromore.model");

    WebServiceTemplate webServiceTemplate = new WebServiceTemplate(messageFactory);
    webServiceTemplate.setMarshaller(serviceMarshaller);
    webServiceTemplate.setUnmarshaller(serviceMarshaller);
    webServiceTemplate.setMessageSender(httpSender);
    webServiceTemplate.setDefaultUri(defaultURI.toString());

    return webServiceTemplate;
  }
  public List<BuildingInfo> getBuildings() throws LogonException {
    if (!session.alreadyLoggedOn())
      throw new LogonException("Not Logged On; Session does not exist");

    GetBuildingsRequest getBuildingsRequest = new GetBuildingsRequest();
    getBuildingsRequest.setSessionId(session.getSessionId());

    return ((GetBuildingsResponse) wsTemplate.marshalSendAndReceive(getBuildingsRequest))
        .getPayload()
        .getGetBuildingsResponseMessage()
        .getBuildings();
  }
  public List<QuestNPCInfo> getQuests(int npcID) throws LogonException {
    if (!session.alreadyLoggedOn())
      throw new LogonException("Not Logged On; Session does not exist");

    GetQuestsNPCRequest questsNPCRequest = new GetQuestsNPCRequest();
    questsNPCRequest.setSessionId(session.getSessionId());
    questsNPCRequest.setNPCID(npcID);

    GetQuestsNPCResponse getQuestsNPCResponse =
        (GetQuestsNPCResponse) wsTemplate.marshalSendAndReceive(questsNPCRequest);

    return getQuestsNPCResponse.getPayload().getQuestsNPCResponseMessage().getQuests();
  }
  public String respawn() throws LogonException {

    // Make sure user is already logged on before letting them logout
    if (!session.alreadyLoggedOn())
      throw new LogonException("Not Logged On; Session does not exist");

    RespawnRequest respawnRequest = new RespawnRequest();
    respawnRequest.setSessionId(session.getSessionId());

    RespawnResponse logoutResponse =
        (RespawnResponse) wsTemplate.marshalSendAndReceive(respawnRequest);

    return logoutResponse.getStatus();
  }
  public void logout() throws LogonException {

    // Make sure user is already logged on before letting them logout
    if (!session.alreadyLoggedOn())
      throw new LogonException("You must first be logged on before calling Logout");

    LogoutRequest logoutRequest = new LogoutRequest();
    logoutRequest.setSessionId(session.getSessionId());

    LogoutResponse logoutResponse =
        (LogoutResponse) wsTemplate.marshalSendAndReceive(logoutRequest);
    System.out.println("logout response = " + logoutResponse.getStatus());
    session.wipe();
  }
  public String runAdminCommand(String adminCommand) throws LogonException {

    // Make sure user is  already logged on
    if (!session.alreadyLoggedOn())
      throw new LogonException("Not Logged On; Session does not exist");

    AdminCommandRequest adminCommandRequest = new AdminCommandRequest();
    adminCommandRequest.setSessionId(session.getSessionId());
    adminCommandRequest.setCommand(adminCommand);

    AdminCommandResponse adminCommandResponse =
        (AdminCommandResponse) wsTemplate.marshalSendAndReceive(adminCommandRequest);

    return adminCommandResponse.getStatus();
  }
  private WebServiceTemplate initializeConnection() {
    // Create message factory
    SOAPMessageFactory1_1Impl impl = new SOAPMessageFactory1_1Impl();
    SaajSoapMessageFactory msgFactory = new SaajSoapMessageFactory(impl);

    msgFactory.setSoapVersion(SoapVersion.SOAP_11);

    // Create an instance of jaxbmarshaller
    HashMap<String, Object> properties = new HashMap<String, Object>();
    properties.put(javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT, false);
    Jaxb2Marshaller marshaller = new Jaxb2Marshaller();

    marshaller.setContextPaths("com.andrewcraft.schema");
    marshaller.setMarshallerProperties(properties);

    CommonsHttpMessageSender msgSender = new CommonsHttpMessageSender();

    WebServiceTemplate wsTemplate = new WebServiceTemplate(msgFactory);
    wsTemplate.setMarshaller(marshaller);
    wsTemplate.setUnmarshaller(marshaller);
    wsTemplate.setMessageSender(msgSender);
    wsTemplate.setDefaultUri(session.getServerAddress());
    return wsTemplate;
  }
  public List<String> playerAttack() throws LogonException {
    if (!session.alreadyLoggedOn())
      throw new LogonException("Not Logged On; Session does not exist");

    AttackEntityRequest attackEntityRequest = new AttackEntityRequest();
    attackEntityRequest.setSessionId(session.getSessionId());

    AttackEntityResponse attackEntityResponse =
        (AttackEntityResponse) wsTemplate.marshalSendAndReceive(attackEntityRequest);

    try {
      return attackEntityResponse.getPayload().getEntity();
    } catch (Exception e) {
      return null;
    }
  }
  /**
   * @see org.apromore.filestore.client.FileStoreService#resetUserPassword(String, String)
   *     {@inheritDoc}
   */
  @Override
  @SuppressWarnings("unchecked")
  public boolean resetUserPassword(String username, String password) {
    LOGGER.debug("Preparing Reset the Users Password.....");

    ResetUserPasswordInputMsgType msg = new ResetUserPasswordInputMsgType();
    msg.setUsername(username);
    msg.setPassword(password);

    JAXBElement<ResetUserPasswordInputMsgType> request =
        WS_CLIENT_FACTORY.createResetUserPasswordRequest(msg);

    JAXBElement<ResetUserPasswordOutputMsgType> response =
        (JAXBElement<ResetUserPasswordOutputMsgType>)
            webServiceTemplate.marshalSendAndReceive(request);
    return response.getValue().isSuccess();
  }
  public void login() throws LogonException {

    // Make sure user is not already logged on
    if (session.alreadyLoggedOn()) throw new LogonException("Already Logged On; Session Exists");

    LoginRequest loginRequest = new LoginRequest();
    loginRequest.setUserName(session.getUserName());

    LoginResponse loginResponse = (LoginResponse) wsTemplate.marshalSendAndReceive(loginRequest);
    System.out.println("login response = " + loginResponse.getSessionId());

    // See if the server returned an error.  If so, throw it to caller as an exception
    if (loginResponse.getSessionId().equalsIgnoreCase("Already Logged On"))
      throw new LogonException(loginResponse.getSessionId());

    session.setSessionId(loginResponse.getSessionId());
  }
  /**
   * @see org.apromore.filestore.client.FileStoreService#writeUser(org.apromore.model.UserType)
   *     {@inheritDoc}
   */
  @Override
  @SuppressWarnings("unchecked")
  public UserType writeUser(UserType user) throws Exception {
    LOGGER.debug("Preparing WriteUserRequest.....");

    WriteUserInputMsgType msg = new WriteUserInputMsgType();
    msg.setUser(user);

    JAXBElement<WriteUserInputMsgType> request = WS_CLIENT_FACTORY.createWriteUserRequest(msg);

    JAXBElement<WriteUserOutputMsgType> response =
        (JAXBElement<WriteUserOutputMsgType>) webServiceTemplate.marshalSendAndReceive(request);
    if (response.getValue().getResult().getCode() == -1) {
      throw new Exception(response.getValue().getResult().getMessage());
    }

    return response.getValue().getUser();
  }
  public double[] updateLocation(double x, double y) throws LogonException {

    // Make sure user is  already logged on
    if (!session.alreadyLoggedOn())
      throw new LogonException("Not Logged On; Session does not exist");

    SetMyLocationRequest setMyLocationRequest = new SetMyLocationRequest();
    setMyLocationRequest.setSessionId(session.getSessionId());
    setMyLocationRequest.setXCooridinate(x);
    setMyLocationRequest.setYCooridinate(y);

    SetMyLocationResponse setMyLocationResponse =
        (SetMyLocationResponse) wsTemplate.marshalSendAndReceive(setMyLocationRequest);

    return new double[] {
      setMyLocationResponse.getModifiedLocationX(), setMyLocationResponse.getModifiedLocationY()
    };
  }
  /** @see org.apromore.filestore.client.FileStoreService#readUserByEmail(String) {@inheritDoc} */
  @Override
  @SuppressWarnings("unchecked")
  public UserType readUserByEmail(String email) throws Exception {
    LOGGER.debug("Preparing ResetUserRequest.....");

    ReadUserByEmailInputMsgType msg = new ReadUserByEmailInputMsgType();
    msg.setEmail(email);

    JAXBElement<ReadUserByEmailInputMsgType> request =
        WS_CLIENT_FACTORY.createReadUserByEmailRequest(msg);

    JAXBElement<ReadUserByEmailOutputMsgType> response =
        (JAXBElement<ReadUserByEmailOutputMsgType>)
            webServiceTemplate.marshalSendAndReceive(request);
    if (response.getValue().getResult().getCode() == -1) {
      throw new Exception(response.getValue().getResult().getMessage());
    } else {
      return response.getValue().getUser();
    }
  }
  /*
   * (non-Javadoc)
   * @see com.bnpparibas.goe.service.edservice.UploadPerformanceDataService#execute(java.lang.String, java.lang.String,
   * java.lang.String, java.lang.String, byte[])
   */
  public Object execute(
      String edCodeText,
      String cutOffDateText,
      String signatureDataText,
      String uploadDateText,
      byte[] fileStream)
      throws Exception {

    UploadPerformanceDataMessageCallback callback =
        new UploadPerformanceDataMessageCallback(new URI(wsAddressingAction));
    callback.setEdCodeText(edCodeText);
    callback.setCutOffDateText(cutOffDateText);
    callback.setSignatureDataText(signatureDataText);
    callback.setUploadDateText(uploadDateText);

    UploadPerformanceDataRequest requestPayload = new UploadPerformanceDataRequest();
    requestPayload.setFilestream(fileStream);

    return (UploadPerformanceDataResponse)
        edwServicesTemplate.marshalSendAndReceive(serviceEndpoint, requestPayload, callback);
  }
  public List<NPCInfo> getNPCInfo() throws LogonException {

    // Make sure user is  already logged on
    if (!session.alreadyLoggedOn())
      throw new LogonException("Not Logged On; Session does not exist");

    // Finally try to get a list of user locations
    GetNPCInfoRequest getNPCInfoRequest = new GetNPCInfoRequest();
    getNPCInfoRequest.setSessionId(session.getSessionId());

    GetNPCInfoResponse getNPCInfoResponse =
        (GetNPCInfoResponse) wsTemplate.marshalSendAndReceive(getNPCInfoRequest);
    List<NPCInfo> npcList;

    try {
      npcList = getNPCInfoResponse.getPayload().getNPCInfoResponseMessage().getNPCs();
    } catch (NullPointerException e) {
      npcList = null;
    }

    return npcList;
  }
Esempio n. 27
0
  public Result verifyCar(AdapterRequest request) {
    CarInfo carInfo = carService.getCarInfoById(request.getCarId());

    VerifyCarRequest req =
        new VerifyCarRequest.Builder()
            .vin(carInfo.getVinString())
            .ecv(carInfo.getEcvString())
            .ico(icoString)
            .irisUser(irisUser)
            .irisPwd(irisPwd)
            .build();

    Document verifyCarResult = null;
    Result result = Result.getInstance(request);
    result.setXmlInput(req.getXmlString());
    try {
      StringWriter respWriter = new StringWriter();
      ispelService.sendSourceAndReceiveToResult(
          new StreamSource(new StringReader(req.getXmlString())), new StreamResult(respWriter));
      result.setXmlOutput(respWriter.toString());
      verifyCarResult = responseResolver.getVerifyCarResult(respWriter.toString());
      result.setXmlOutput(xmlOutputter.get().outputString(verifyCarResult));
      carService.processVerifyCar(carInfo, verifyCarResult);
    } catch (Exception e) {
      logger.error(e);
      result.setProcessed(Result.UNPROCESSED);
      result.setErrorText(e.getMessage());
    }

    try {
      logService.logResult(result);
    } catch (Exception e) {
      logger.error("Log result error.");
      logger.error(e);
    }
    return result;
  }