@Override public Exception call() throws Exception { try { if ( log.isBasic() ) { log.logBasic( BaseMessages.getString( PKG, "PurRepositoryConnector.CreateRepositorySyncWebService.Start" ) ); } IRepositorySyncWebService syncWebService = serviceManager.createService( username, decryptedPassword, IRepositorySyncWebService.class ); //$NON-NLS-1$ if ( log.isBasic() ) { log.logBasic( BaseMessages.getString( PKG, "PurRepositoryConnector.CreateRepositorySyncWebService.Sync" ) ); //$NON-NLS-1$ } syncWebService.sync( repositoryMeta.getName(), repositoryMeta.getRepositoryLocation().getUrl() ); } catch ( RepositorySyncException e ) { log.logError( e.getMessage(), e ); // this message will be presented to the user in spoon result.setConnectMessage( e.getMessage() ); return null; } catch ( ClientTransportException e ) { // caused by authentication errors, etc return e; } catch ( WebServiceException e ) { // if we can speak to the repository okay but not the sync service, assume we're talking to a BA Server log.logError( e.getMessage(), e ); return new Exception( BaseMessages.getString( PKG, "PurRepository.BAServerLogin.Message" ), e ); } return null; } } );
log.logError( repoException.getMessage() ); throw new Exception( BaseMessages.getString( PKG, "PurRepository.FailedLogin.Message" ), repoException );
private RuntimeException unwrap(WebServiceException ex) { RuntimeException result = ex; String message = ex.getMessage(); String prefix = SecurityException.class.getName() + ": "; if (message.startsWith(prefix)) { message = message.substring(prefix.length()); result = new SecurityException (message); } return result; } }
/** * Returns true if the WebServiceException was thrown as a result of an invalid service name. * * @param e the exception * @return true if the WebServiceException was thrown as a result of an invalid service name * @throws Fabric3Exception if the exception message cannot be parsed */ private boolean isInvalidServiceName(WebServiceException e) throws Fabric3Exception { String message = ClientMessages.INVALID_SERVICE_NAME(serviceName, null); int index = message.indexOf("null"); if (index < 1) { throw new Fabric3Exception("Unable to parse error message after proxy creation error was thrown: " + message, e); } message = message.substring(0, index); return e.getMessage().contains(message); }
/** * Returns true if the WebServiceException was thrown as a result of an invalid service name. * * @param e the exception * @return true if the WebServiceException was thrown as a result of an invalid service name * @throws ObjectCreationException if the exception message cannot be parsed */ private boolean isInvalidServiceName(WebServiceException e) throws ObjectCreationException { String message = ClientMessages.INVALID_SERVICE_NAME(serviceName, null); int index = message.indexOf("null"); if (index < 1) { throw new ObjectCreationException("Unable to parse error message after proxy creation error was thrown: " + message, e); } message = message.substring(0, index); return e.getMessage().contains(message); }
public void triggerSynchronization() { try { logger.info("call to trigger synchro"); myStub.triggerSynchronization(new TriggerSynchronization()); } catch (SOAPFaultException sfe) { // sfe.printStackTrace(); lastError = "SOAP Fault while call to triggerSynchronization (SDNManagement). " + sfe.getFault().getFaultString() + " (Fault code : " + sfe.getFault().getFaultCode() + ")."; logger.error(lastError); } catch (WebServiceException wse) { // wse.printStackTrace(); lastError = "Unable to call triggerSynchronization (SDNManagement) (" + wse.getClass().getName() + ") " + wse.getMessage(); logger.error(lastError); } catch (Exception e) { e.printStackTrace(); lastError = "Problem when calling service :" + e.getMessage(); logger.error(lastError); } return; }
public void triggerSynchronization() { try { myStub.triggerSynchronization(new TriggerSynchronization()); } catch (SOAPFaultException sfe) { // sfe.printStackTrace(); lastError = "SOAP Fault while call to triggerSynchronization (UserManagement). " + sfe.getFault().getFaultString() + " (Fault code : " + sfe.getFault().getFaultCode() + ")."; logger.error(lastError); } catch (WebServiceException wse) { // wse.printStackTrace(); lastError = "Unable to call triggerSynchronization (UserManagement) (" + wse.getClass().getName() + ") " + wse.getMessage(); logger.error(lastError); } catch (Exception e) { e.printStackTrace(); lastError = "Problem when calling service :" + e.getMessage(); logger.error(lastError); } return; }
public void disconnect() { if (isConnected && myStub != null) { try { myStub.disconnect(new Disconnect()); } catch (SOAPFaultException sfe) { // sfe.printStackTrace(); lastError = "SOAP Fault while call to disconnect (SDNManagement). " + sfe.getFault().getFaultString() + " (Fault code : " + sfe.getFault().getFaultCode() + ")."; logger.error(lastError); } catch (WebServiceException wse) { // wse.printStackTrace(); lastError = "Unable to call disconnect (SDNManagement) (" + wse.getClass().getName() + ") " + wse.getMessage(); logger.error(lastError); } catch (Exception e) { e.printStackTrace(); lastError = "Problem when calling service :" + e.getMessage(); logger.error(lastError); } isConnected = false; } logger.info("SDNManagementClient Session disconnected."); }
public void disconnect() { if (isConnected && myStub != null) { try { myStub.disconnect(new Disconnect()); } catch (SOAPFaultException sfe) { // wse.printStackTrace(); lastError = "SOAP Fault while call to disconnect (EtradealSettings). " + sfe.getFault().getFaultString() + " (Fault code : " + sfe.getFault().getFaultCode() + ")."; logger.error(lastError); } catch (WebServiceException wse) { // wse.printStackTrace(); lastError = "Unable to call disconnect (EtradealSettings) (" + wse.getClass().getName() + ") " + wse.getMessage(); logger.error(lastError); } catch (Exception e) { e.printStackTrace(); lastError = "Problem when calling service " + e.getMessage(); logger.error(lastError); } isConnected = false; } logger.info("EtradealSettingsClient Session disconnected."); }
public void setDefaultTrunk(int type) { SetDefaultTrunkType parameters = new SetDefaultTrunkType(); parameters.setTrunkType(type); try { myStub.setDefaultTrunkType(parameters); } catch (SOAPFaultException sfe) { // sfe.printStackTrace(); lastError = "SOAP Fault while call to setDefaultTrunk (SDNManagement). " + sfe.getFault().getFaultString() + " (Fault code : " + sfe.getFault().getFaultCode() + ")."; logger.error(lastError); } catch (WebServiceException wse) { // wse.printStackTrace(); lastError = "Unable to call setDefaultTrunk (SDNManagement) (" + wse.getClass().getName() + ") " + wse.getMessage(); logger.error(lastError); } catch (Exception e) { e.printStackTrace(); lastError = "Problem when calling service. " + e.getMessage(); logger.error(lastError); } }
public int getDefaultTrunk() { int defaultTrunkType = -1; GetDefaultTrunkType parameters = new GetDefaultTrunkType(); try { defaultTrunkType = myStub.getDefaultTrunkType(parameters).getGetDefaultTrunkTypeResult(); } catch (SOAPFaultException sfe) { // sfe.printStackTrace(); lastError = "SOAP Fault while call to getDefaultTrunk (SDNManagement). " + sfe.getFault().getFaultString() + " (Fault code : " + sfe.getFault().getFaultCode() + ")."; logger.error(lastError); } catch (WebServiceException wse) { // wse.printStackTrace(); lastError = "Unable to call getDefaultTrunk (SDNManagement) (" + wse.getClass().getName() + ") " + wse.getMessage(); logger.error(lastError); } catch (Exception e) { e.printStackTrace(); lastError = "Problem when calling service. " + e.getMessage(); logger.error(lastError); } return defaultTrunkType; }
public List<SystemDeletedFromUser> deleteSystemsFromUser(List<SystemToDeleteFromUser> systemsToDelete) { List<SystemDeletedFromUser> systemsDeleted = null; ArrayOfSystemToDeleteFromUser uA = new ArrayOfSystemToDeleteFromUser(); if (systemsToDelete != null) uA.getSystemToDeleteFromUser().addAll(systemsToDelete); DeleteSystemsFromUsers parameters = new DeleteSystemsFromUsers(); parameters.setO(uA); try { // TODO : use returned objects myStub.deleteSystemsFromUsers(parameters); } catch (SOAPFaultException sfe) { // sfe.printStackTrace(); logger.error("SOAP Fault while call to deleteSystemsFromUser (UserManagement). " + sfe.getFault().getFaultString() + " (Fault code : " + sfe.getFault().getFaultCode() + ")."); } catch (WebServiceException wse) { // wse.printStackTrace(); logger.error("Unable to call deleteSystemsFromUser (UserManagement) (" + wse.getClass().getName() + ") " + wse.getMessage()); } catch (Exception e) { e.printStackTrace(); logger.error("Problem when calling service"); } return systemsDeleted; }
@Test public void testLogicalHandlerHandleMessageThrowsProtocolExceptionServerInbound() throws PingException { try { handlerTest.pingWithArgs("handler2 inbound throw ProtocolException"); fail("did not get expected exception"); } catch (WebServiceException e) { assertTrue(e.getMessage().indexOf("HandleMessage throws exception") >= 0); } }
@Test public void testWithNoAlternativeEndpoints() throws Exception { final Greeter g = getGreeter(REPLICA_E); try { g.greetMe("fred"); fail("Expecting communication exception"); } catch (WebServiceException ex) { assertThat(ex.getMessage(), equalTo("Could not send Message.")); } try { g.greetMe("fred"); fail("Expecting no alternative endpoints exception"); } catch (SOAPFaultException ex) { assertThat(ex.getMessage(), equalTo("None of alternative addresses are available at the moment")); } }
@Test public void testSOAPHandlerHandleFaultThrowsRuntimeExceptionServerOutbound() throws PingException { try { handlerTest.pingWithArgs("soapHandler3 inbound throw ProtocolException " + "soapHandler4HandleFaultThrowsRunException"); fail("did not get expected WebServiceException"); } catch (WebServiceException e) { assertEquals("soapHandler4 HandleFault throws RuntimeException", e.getMessage()); } }
@Test public void testSOAPHandlerHandleMessageThrowsProtocolExceptionServerOutbound() throws PingException { try { handlerTest.pingWithArgs("soapHandler3 outbound throw ProtocolException"); fail("did not get expected WebServiceException"); } catch (WebServiceException e) { assertEquals("HandleMessage throws exception", e.getMessage()); } }
@Test public void testSOAPHandlerHandleMessageThrowsProtocolExceptionServerInbound() throws PingException { try { handlerTest.pingWithArgs("soapHandler3 inbound throw ProtocolException"); fail("did not get expected WebServiceException"); } catch (WebServiceException e) { assertEquals("HandleMessage throws exception", e.getMessage()); } } @Test
@Test public void testWithAlternativeEnpdpoints() throws Exception { final Greeter g = getGreeter(REPLICA_A); startTarget(REPLICA_E); try { final String response = g.greetMe("fred"); assertNotNull("expected non-null response", response); } finally { stopTarget(REPLICA_E); } try { g.greetMe("fred"); fail("Expecting no alternative endpoints exception"); } catch (WebServiceException ex) { assertThat(ex.getMessage(), equalTo("Could not send Message.")); } } }
@Test public void testSchemaValidationServerForMethod() throws Exception { SchemaValidation validation = createService(Boolean.FALSE, "SoapPortMethodValidate"); ComplexStruct complexStruct = new ComplexStruct(); complexStruct.setElem1("one"); complexStruct.setElem3(3); try { validation.setComplexStruct(complexStruct); fail("Set ComplexStruct should have thrown ProtocolException"); } catch (WebServiceException e) { String expected = "'{\"http://apache.org/schema_validation/types\":elem2}' is expected."; assertTrue(e.getMessage(), e.getMessage().indexOf(expected) != -1); } SchemaValidation novlidation = createService(Boolean.FALSE, "SoapPort"); try { novlidation.setComplexStruct(complexStruct); } catch (WebServiceException e) { fail("Exception is not expected :" + e); } }
private void doProviderTest(String postfix) throws Exception { SchemaValidation validation = createService(Boolean.FALSE, postfix); SomeRequest req = new SomeRequest(); req.setId("9999999999"); try { validation.doSomething(req); fail("Should have faulted"); } catch (DoSomethingFault e) { assertEquals("1234", e.getFaultInfo().getErrorCode()); } req.setId("8888888888"); try { validation.doSomething(req); fail("Should have faulted"); } catch (DoSomethingFault e) { fail("Should not have happened"); } catch (WebServiceException e) { String expected = "Value '1' is not facet-valid"; assertTrue(e.getMessage().indexOf(expected) != -1); } ((java.io.Closeable)validation).close(); }