Search in sources :

Example 16 with RemoteCallReturn

use of com.google.api.ads.common.lib.client.RemoteCallReturn in project googleads-java-lib by googleads.

the class SoapServiceClientTest method testCallSoapClient.

@Test
@SuppressWarnings("unchecked")
public void testCallSoapClient() throws Throwable {
    RemoteCallReturn expectedRemoteCallReturn = new RemoteCallReturn.Builder().build();
    SoapCall<Object> soapCall = Mockito.mock(SoapCall.class);
    when(soapClientHandler.invokeSoapCall(soapCall)).thenReturn(expectedRemoteCallReturn);
    RemoteCallReturn remoteCallReturn = soapServiceClient.callSoapClient(soapCall);
    assertSame(expectedRemoteCallReturn, remoteCallReturn);
}
Also used : RemoteCallReturn(com.google.api.ads.common.lib.client.RemoteCallReturn) Test(org.junit.Test)

Example 17 with RemoteCallReturn

use of com.google.api.ads.common.lib.client.RemoteCallReturn in project googleads-java-lib by googleads.

the class AxisHandler method invokeSoapCall.

/**
 * Invoke a SOAP call.
 *
 * @param soapCall the call to make to a SOAP web service
 * @return information about the SOAP response
 */
@Override
public RemoteCallReturn invokeSoapCall(SoapCall<Stub> soapCall) {
    Stub stub = soapCall.getSoapClient();
    RemoteCallReturn.Builder builder = new RemoteCallReturn.Builder();
    synchronized (stub) {
        Object result = null;
        try {
            result = invoke(soapCall);
        } catch (InvocationTargetException e) {
            builder.withException(e.getTargetException());
        } catch (Exception e) {
            builder.withException(e);
        } finally {
            MessageContext messageContext = stub._getCall().getMessageContext();
            RequestInfo.Builder requestInfoBuilder = new RequestInfo.Builder().withMethodName(stub._getCall().getOperationName().getLocalPart()).withServiceName(stub._getService().getServiceName().getLocalPart()).withUrl(stub._getCall().getTargetEndpointAddress());
            requestInfoXPathSet.parseMessage(requestInfoBuilder, messageContext.getRequestMessage());
            builder.withRequestInfo(requestInfoBuilder.build());
            ResponseInfo.Builder responseInfoBuilder = new ResponseInfo.Builder();
            responseInfoXPathSet.parseMessage(responseInfoBuilder, messageContext.getResponseMessage());
            builder.withResponseInfo(responseInfoBuilder.build());
        }
        return builder.withReturnValue(result).build();
    }
}
Also used : ResponseInfo(com.google.api.ads.common.lib.client.ResponseInfo) Stub(org.apache.axis.client.Stub) MessageContext(org.apache.axis.MessageContext) RequestInfo(com.google.api.ads.common.lib.client.RequestInfo) InvocationTargetException(java.lang.reflect.InvocationTargetException) SOAPException(javax.xml.soap.SOAPException) ServiceException(com.google.api.ads.common.lib.exception.ServiceException) InvocationTargetException(java.lang.reflect.InvocationTargetException) RemoteCallReturn(com.google.api.ads.common.lib.client.RemoteCallReturn)

Aggregations

RemoteCallReturn (com.google.api.ads.common.lib.client.RemoteCallReturn)17 Test (org.junit.Test)11 ResponseInfo (com.google.api.ads.common.lib.client.ResponseInfo)8 RequestInfo (com.google.api.ads.common.lib.client.RequestInfo)7 Matchers.containsString (org.hamcrest.Matchers.containsString)3 ServiceException (com.google.api.ads.common.lib.exception.ServiceException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Method (java.lang.reflect.Method)2 SOAPException (javax.xml.soap.SOAPException)2 BindingProvider (javax.xml.ws.BindingProvider)2 BatchJobMutateResultInterface (com.google.api.ads.adwords.lib.utils.BatchJobMutateResultInterface)1 BatchJobUploadResponse (com.google.api.ads.adwords.lib.utils.BatchJobUploadResponse)1 ReportException (com.google.api.ads.adwords.lib.utils.ReportException)1 SoapCall (com.google.api.ads.common.lib.soap.SoapCall)1 CampaignServiceInterface (com.google.api.ads.common.lib.soap.jaxws.testing.mocks.CampaignServiceInterface)1 CampaignServiceInterfaceImpl (com.google.api.ads.common.lib.soap.jaxws.testing.mocks.CampaignServiceInterfaceImpl)1 InputStream (java.io.InputStream)1 MessageContext (org.apache.axis.MessageContext)1 Stub (org.apache.axis.client.Stub)1