.invoke(locator, soapServiceDescriptor.getInterfaceClass()); throw new ServiceException( "Service [" + soapServiceDescriptor + "] not compatible with Axis", null); } catch (SecurityException e) { throw new ServiceException("Unexpected Exception.", e); } catch (NoSuchMethodException e) { throw new ServiceException("Unexpected Exception.", e); } catch (IllegalArgumentException e) { throw new ServiceException("Unexpected Exception.", e); } catch (IllegalAccessException e) { throw new ServiceException("Unexpected Exception.", e); } catch (InvocationTargetException e) { throw new ServiceException("Unexpected Exception.", e); } catch (ClassNotFoundException e) { throw new ServiceException("Unexpected Exception.", e); } catch (InstantiationException e) { throw new ServiceException("Unexpected Exception.", e);
.invoke(locator, soapServiceDescriptor.getInterfaceClass()); throw new ServiceException( "Service [" + soapServiceDescriptor + "] not compatible with Axis", null); } catch (SecurityException e) { throw new ServiceException("Unexpected Exception.", e); } catch (NoSuchMethodException e) { throw new ServiceException("Unexpected Exception.", e); } catch (IllegalArgumentException e) { throw new ServiceException("Unexpected Exception.", e); } catch (IllegalAccessException e) { throw new ServiceException("Unexpected Exception.", e); } catch (InvocationTargetException e) { throw new ServiceException("Unexpected Exception.", e); } catch (ClassNotFoundException e) { throw new ServiceException("Unexpected Exception.", e); } catch (InstantiationException e) { throw new ServiceException("Unexpected Exception.", e);
/** * @see SoapClientHandler#setHeader(Object, String, String, Object) */ @Override public void setHeader(BindingProvider soapClient, String namespace, String headerName, Object headerValue) { if (headerValue instanceof SOAPElement) { getContextHandlerFromClient(soapClient).addHeader(namespace, headerName, (SOAPElement) headerValue); } else { throw new ServiceException("Unexpected SOAP header given for JAX-WS binding. Given " + "object of class \"" + headerValue.getClass().toString() + "\" but expecting " + "object of class \"" + SOAPElement.class + "\".", null); } }
/** * @see SoapClientHandler#setHeader(Object, String, String, Object) */ @Override public void setHeader(BindingProvider soapClient, String namespace, String headerName, Object headerValue) { if (headerValue instanceof SOAPElement) { getContextHandlerFromClient(soapClient).addHeader(namespace, headerName, (SOAPElement) headerValue); } else { throw new ServiceException("Unexpected SOAP header given for JAX-WS binding. Given " + "object of class \"" + headerValue.getClass().toString() + "\" but expecting " + "object of class \"" + SOAPElement.class + "\".", null); } }
return soapClient; throw new ServiceException( "Service [" + soapServiceDescriptor + "] is not compatible with JAX-WS", null); } catch (SecurityException e) { throw new ServiceException("Unexpected Exception.", e); } catch (NoSuchMethodException e) { throw new ServiceException("Unexpected Exception.", e); } catch (IllegalArgumentException e) { throw new ServiceException("Unexpected Exception.", e); } catch (IllegalAccessException e) { throw new ServiceException("Unexpected Exception.", e); } catch (InvocationTargetException e) { throw new ServiceException("Unexpected Exception.", e.getCause()); } catch (ClassNotFoundException e) { throw new ServiceException("Unexpected Exception.", e); } catch (InstantiationException e) { throw new ServiceException("Unexpected Exception.", e);
/** * Updates the child attribute of headerName named childName to childValue. * * @param soapClient the stub * @param parentHeaderName the name of the parent header * @param childName the name of the child * @param childValue the value for the child * * @throws NullPointerException if no header exists named parentHeaderName */ public void setHeaderChild(Stub soapClient, String parentHeaderName, String childName, Object childValue) { SOAPHeaderElement headerElement = (SOAPHeaderElement) getHeader(soapClient, parentHeaderName); Object headerObject = Preconditions.checkNotNull(headerElement, "Parent header named %s does not exist", parentHeaderName).getObjectValue(); try { BeanUtils.setProperty(headerObject, childName, childValue); } catch (IllegalAccessException e) { throw new ServiceException("Failed to set header child " + childName, e); } catch (InvocationTargetException e) { throw new ServiceException("Failed to set header child " + childName, e); } }
return soapClient; throw new ServiceException( "Service [" + soapServiceDescriptor + "] is not compatible with JAX-WS", null); } catch (SecurityException e) { throw new ServiceException("Unexpected Exception.", e); } catch (NoSuchMethodException e) { throw new ServiceException("Unexpected Exception.", e); } catch (IllegalArgumentException e) { throw new ServiceException("Unexpected Exception.", e); } catch (IllegalAccessException e) { throw new ServiceException("Unexpected Exception.", e); } catch (InvocationTargetException e) { throw new ServiceException("Unexpected Exception.", e.getCause()); } catch (ClassNotFoundException e) { throw new ServiceException("Unexpected Exception.", e); } catch (InstantiationException e) { throw new ServiceException("Unexpected Exception.", e);
/** * Updates the child attribute of headerName named childName to childValue. * * @param soapClient the stub * @param parentHeaderName the name of the parent header * @param childName the name of the child * @param childValue the value for the child * * @throws NullPointerException if no header exists named parentHeaderName */ public void setHeaderChild(Stub soapClient, String parentHeaderName, String childName, Object childValue) { SOAPHeaderElement headerElement = (SOAPHeaderElement) getHeader(soapClient, parentHeaderName); Object headerObject = Preconditions.checkNotNull(headerElement, "Parent header named %s does not exist", parentHeaderName).getObjectValue(); try { BeanUtils.setProperty(headerObject, childName, childValue); } catch (IllegalAccessException e) { throw new ServiceException("Failed to set header child " + childName, e); } catch (InvocationTargetException e) { throw new ServiceException("Failed to set header child " + childName, e); } }
/** * Adds a child text node named childName to the existing header named headerName. * * @param soapClient the binding provider * @param headerName the name of the existing header * @param childNamespace the namespace of the new child * @param childName the name of the new child * @param childValue the value of the new child * * @throws NullPointerException if no header exists named headerName */ public void setHeaderChildString(BindingProvider soapClient, final String headerName, String childNamespace, String childName, String childValue) { // Find the parent header SOAPElement SOAPElement parentHeader = (SOAPElement) getHeader(soapClient, headerName); Preconditions.checkNotNull(parentHeader, "No header element found with name: %s", headerName); // Add a SOAPElement for the child try { SOAPElement childElement = parentHeader.addChildElement(new QName(childNamespace, childName)); childElement.setTextContent(childValue); } catch (SOAPException e) { throw new ServiceException("Failed to set header for child " + childName, e); } }
/** * Adds a child text node named childName to the existing header named headerName. * * @param soapClient the binding provider * @param headerName the name of the existing header * @param childNamespace the namespace of the new child * @param childName the name of the new child * @param childValue the value of the new child * * @throws NullPointerException if no header exists named headerName */ public void setHeaderChildString(BindingProvider soapClient, final String headerName, String childNamespace, String childName, String childValue) { // Find the parent header SOAPElement SOAPElement parentHeader = (SOAPElement) getHeader(soapClient, headerName); Preconditions.checkNotNull(parentHeader, "No header element found with name: %s", headerName); // Add a SOAPElement for the child try { SOAPElement childElement = parentHeader.addChildElement(new QName(childNamespace, childName)); childElement.setTextContent(childValue); } catch (SOAPException e) { throw new ServiceException("Failed to set header for child " + childName, e); } }
/** * @see SoapClientHandler#setHeader(Object, String, String, Object) */ @Override public void setHeader(Stub soapClient, String namespace, String headerName, Object headerValue) { try { QName qName = new QName(namespace, headerName); SOAPHeaderElement soapHeaderElement = new SOAPHeaderElement(qName); soapHeaderElement.setObjectValue(headerValue); soapHeaderElement.setActor(null); soapClient.setHeader(soapHeaderElement); } catch (SOAPException e) { throw new ServiceException("Could not set header.", e); } }
/** * @see SoapClientHandler#setHeader(Object, String, String, Object) */ @Override public void setHeader(Stub soapClient, String namespace, String headerName, Object headerValue) { try { QName qName = new QName(namespace, headerName); SOAPHeaderElement soapHeaderElement = new SOAPHeaderElement(qName); soapHeaderElement.setObjectValue(headerValue); soapHeaderElement.setActor(null); soapClient.setHeader(soapHeaderElement); } catch (SOAPException e) { throw new ServiceException("Could not set header.", e); } }
throw new ServiceException("Unexpected exception.", e);
soapClientHandler.setRequestTimeout(stub, adsLibConfiguration.getSoapRequestTimeout()); } catch (InstantiationException e) { throw new ServiceException("Unexpected exception.", e); } catch (IllegalAccessException e) { throw new ServiceException("Unexpected exception.", e); } catch (ClassNotFoundException e) { throw new ServiceException("Unexpected exception.", e); } catch (InvocationTargetException e) { throw new ServiceException("Unexpected exception.", e); } catch (IllegalArgumentException e) { throw new ServiceException("Unexpected exception.", e); } catch (SecurityException e) { throw new ServiceException("Unexpected exception.", e);
throw new ServiceException( "Unexpected exception constructing SOAP header for: " + adWordsServiceDescriptor, e);
/** * Creates an {@link AdsServiceClient} given an {@link AdsServiceDescriptor} * descriptor and an {@link AdsSession}. * * @param adsServiceDescriptor descriptor with information on ads service * @param adsSession the session associated with the desired * client * @return the created {@link AdsServiceClient} * @throws ServiceException if the ads service client could not be created */ @Override public C createAdsServiceClient(D adsServiceDescriptor, S adsSession) throws ServiceException { Object soapClient = createSoapClient(adsServiceDescriptor); C adsServiceClient = createServiceClient(soapClient, adsServiceDescriptor, adsSession); try { adsServiceClient.setEndpointAddress(adsServiceDescriptor.getEndpointAddress(adsSession .getEndpoint())); } catch (MalformedURLException e) { throw new ServiceException("Unexpected exception", e); } return adsServiceClient; }
/** * Creates an {@link AdsServiceClient} given an {@link AdsServiceDescriptor} * descriptor and an {@link AdsSession}. * * @param adsServiceDescriptor descriptor with information on ads service * @param adsSession the session associated with the desired * client * @return the created {@link AdsServiceClient} * @throws ServiceException if the ads service client could not be created */ @Override public C createAdsServiceClient(D adsServiceDescriptor, S adsSession) throws ServiceException { Object soapClient = createSoapClient(adsServiceDescriptor); C adsServiceClient = createServiceClient(soapClient, adsServiceDescriptor, adsSession); try { adsServiceClient.setEndpointAddress(adsServiceDescriptor.getEndpointAddress(adsSession .getEndpoint())); } catch (MalformedURLException e) { throw new ServiceException("Unexpected exception", e); } return adsServiceClient; }
/** * Test to verify that a ServiceException is thrown if the preconditions check by the underlying * AdsServiceClientFactoryHelper fails. */ @Test public void testGetServiceClient_failPreconditions() { String version = "v1.1"; ServiceException serviceException = new ServiceException("A service exception"); doThrow(serviceException) .when(adsServiceClientFactoryHelper) .checkServiceClientPreconditions(adsSession, MockSoapClientInterface.class); when(adsServiceClientFactoryHelper.determineVersion(MockSoapClientInterface.class)) .thenReturn(version); when( adsServiceClientFactoryHelper.createServiceDescriptor( MockSoapClientInterface.class, version)).thenReturn(adsServiceDescriptor); when(adsServiceClientFactoryHelper.createAdsServiceClient(adsServiceDescriptor, adsSession)) .thenReturn(adsServiceClient); Mockito.<Class<?>>when(adsServiceDescriptor.getInterfaceClass()) .thenReturn(MockSoapClientInterface.class); when(adsServiceClient.getSoapClient()).thenReturn(soapServiceClient); thrown.expect(Matchers.<Exception>is(serviceException)); adsServiceClientFactory.getServiceClient(adsSession, MockSoapClientInterface.class); } }
throw new ServiceException("Error setting SOAP headers on outbound message.", e);
throw new ServiceException("Error setting SOAP headers on outbound message.", e);