org.apache.axis.client.Call Java Examples

The following examples show how to use org.apache.axis.client.Call. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AxisClientPluginIT.java    From glowroot with Apache License 2.0 6 votes vote down vote up
@Override
public void transactionMarker() throws Exception {
    String endpoint = "http://localhost:" + port + "/cxf/helloWorld";

    Service service = new Service();
    Call call = (Call) service.createCall();

    call.setTargetEndpointAddress(new URL(endpoint));
    call.setPortTypeName(
            new QName("http://httpclient.plugin.agent.glowroot.org/", "HelloWorld"));
    call.setOperationName(
            new QName("http://httpclient.plugin.agent.glowroot.org/", "hello"));

    call.invoke(new Object[0]);
}
 
Example #2
Source File: AxisClientImpl.java    From tomee with Apache License 2.0 6 votes vote down vote up
/**
 *
 * @param context MessageContext
 * @return HandlerChain
 */
@Override
protected HandlerChain getJAXRPChandlerChain(MessageContext context) {
    QName portQName = (QName) context.getProperty(Call.WSDL_PORT_NAME);
    if (portQName == null) {
        return null;
    }
    String portName = portQName.getLocalPart();

    SeiFactory seiFactory = (SeiFactory) portNameToSEIFactoryMap.get(portName);
    if (seiFactory == null) {
        return null;
    }
    HandlerChain handlerChain = seiFactory.createHandlerChain();
    return handlerChain;
}
 
Example #3
Source File: SOAPUtils.java    From webcurator with Apache License 2.0 5 votes vote down vote up
/**
 * Register a set of types against the SOAP call.
 * @param call The call to register against.
 * @param classes The classes to register.
 */
public static void regTypes(Call call, Class...classes) {
	for(int i=0; i<classes.length; i++) {
		Mapping mapping = REG_CLASS_TYPES.get(classes[i]);
		if(mapping != null) {
			call.registerTypeMapping(classes[i], mapping.qname, mapping.serializer, mapping.deserializer);
		}
	}
}
 
Example #4
Source File: SOAPUtils.java    From webcurator with Apache License 2.0 5 votes vote down vote up
/**
 * Register a type against the SOAP call.
 * @param call The call to register against.
 * @param clazz The class to register.
 */	
public static void regType(Call call, Class clazz) {
	Mapping mapping = REG_CLASS_TYPES.get(clazz);
	if(mapping != null) {
		call.registerTypeMapping(clazz, mapping.qname, mapping.serializer, mapping.deserializer);
	}
}
 
Example #5
Source File: SOAPUtils.java    From webcurator with Apache License 2.0 5 votes vote down vote up
/**
 * Register types against the SOAP call.
 * @param call The call to register against.
 * @param objects The objects that are to be passed to the Call object. This method 
 *                will determine the type of the object and register those types.
 */		
public static void regTypes(Call call, Object...objects) {
	for(int i=0; i<objects.length; i++) {
		Mapping mapping = REG_CLASS_TYPES.get(objects[i].getClass());
		if(mapping != null) {
			call.registerTypeMapping(objects[i].getClass(), mapping.qname, mapping.serializer, mapping.deserializer);
		}
	}
}
 
Example #6
Source File: AxisContextHelper.java    From j-road with Apache License 2.0 5 votes vote down vote up
public void afterPropertiesSet() throws Exception {
  Stub stub = stubClass.getConstructor(Service.class).newInstance(new Object[] { null });
  for (Method m : stub.getClass().getDeclaredMethods()) {
    if (m.getName().equals("createCall")) {
      m.setAccessible(true);
      messageContext = ((Call) m.invoke(stub)).getMessageContext();
      break;
    }
  }
  if (messageContext == null) {
    throw new IllegalStateException("Could not find the createCall() method in the stub supplied!");
  }
}
 
Example #7
Source File: OperationInfo.java    From tomee with Apache License 2.0 5 votes vote down vote up
public void prepareCall(Call call) {
    call.setOperation(operationDesc);
    call.setUseSOAPAction(useSOAPAction);
    call.setSOAPActionURI(soapActionURI);
    call.setSOAPVersion(soapVersion);
    call.setOperationName(operationName);
    //GAH!!!
    call.setOperationStyle(operationDesc.getStyle());
    call.setOperationUse(operationDesc.getUse());
}
 
Example #8
Source File: AxisClientAspect.java    From glowroot with Apache License 2.0 4 votes vote down vote up
@OnBefore
public static TraceEntry onBefore(ThreadContext context, @BindReceiver Call call) {
    String url = call.getTargetEndpointAddress();
    return context.startServiceCallEntry("HTTP", "POST " + url,
            MessageSupplier.create("http client request: POST {}", url), timerName);
}
 
Example #9
Source File: ServiceEndpointMethodInterceptor.java    From tomee with Apache License 2.0 4 votes vote down vote up
private Object doIntercept(Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
        int index = methodProxy.getSuperIndex();
        OperationInfo operationInfo = operations[index];
        if (operationInfo == null) {
            throw new ServerRuntimeException("Operation not mapped: " + method.getName() + " index: " + index + "\n OperationInfos: " + Arrays.asList(operations));
        }
        stub.checkCachedEndpoint();

        Call call = stub.createCall();

        operationInfo.prepareCall(call);

        stub.setUpCall(call);
        if (credentialsName != null) {
            throw new UnsupportedOperationException("Client side auth is not implementd");
//            Subject subject = ContextManager.getNextCaller();
//            if (subject == null) {
//                throw new IllegalStateException("Subject missing but authentication turned on");
//            } else {
//                Set creds = subject.getPrivateCredentials(NamedUsernamePasswordCredential.class);
//                boolean found = false;
//                for (Iterator iterator = creds.iterator(); iterator.hasNext();) {
//                    NamedUsernamePasswordCredential namedUsernamePasswordCredential = (NamedUsernamePasswordCredential) iterator.next();
//                    if (credentialsName.equals(namedUsernamePasswordCredential.getName())) {
//                        call.setUsername(namedUsernamePasswordCredential.getUsername());
//                        call.setPassword(new String(namedUsernamePasswordCredential.getPassword()));
//                        found = true;
//                        break;
//                    }
//                }
//                if (!found) {
//                    throw new IllegalStateException("no NamedUsernamePasswordCredential found for name " + credentialsName);
//                }
//            }
        }
        Object response = null;
        List parameterDescs = operationInfo.getOperationDesc().getParameters();
        Object[] unwrapped = extractFromHolders(objects, parameterDescs, operationInfo.getOperationDesc().getNumInParams());
        if (operationInfo.getOperationDesc().getMep() == OperationType.REQUEST_RESPONSE) {
            try {
                response = call.invoke(unwrapped);
            } catch (RemoteException e) {
                throw operationInfo.unwrapFault(e);
            }

            if (response instanceof RemoteException) {
                throw operationInfo.unwrapFault((RemoteException) response);
            } else {
                stub.extractAttachments(call);
                Map outputParameters = call.getOutputParams();
                putInHolders(outputParameters, objects, parameterDescs);
                Class returnType = operationInfo.getOperationDesc().getReturnClass();
                //return type should never be null... but we are not objecting if wsdl-return-value-mapping is not set.
                if (response == null || returnType == null || returnType.isAssignableFrom(response.getClass())) {
                    return response;
                } else {
                    return JavaUtils.convert(response, returnType);
                }
            }
        } else if (operationInfo.getOperationDesc().getMep() == OperationType.ONE_WAY) {
            //one way
            call.invokeOneWay(unwrapped);
            return null;
        } else {
            throw new ServerRuntimeException("Invalid messaging style: " + operationInfo.getOperationDesc().getMep());
        }
    }
 
Example #10
Source File: GenericServiceEndpointWrapper.java    From tomee with Apache License 2.0 4 votes vote down vote up
public void extractAttachments(Call call) {
    genericServiceEndpoint.extractAttachments(call);
}
 
Example #11
Source File: GenericServiceEndpoint.java    From tomee with Apache License 2.0 4 votes vote down vote up
void setUpCall(Call call) throws AxisFault {
    setRequestHeaders(call);
    setAttachments(call);
}
 
Example #12
Source File: WCTSoapCall.java    From webcurator with Apache License 2.0 3 votes vote down vote up
/**
 * Create a new SOAP call.
 * @param host       The host to send the message to.
 * @param port		 The port the end point is listening on.
 * @param service    The name of the service to send the message to.
 * @param operation  The operation to invoke.
 * @throws ServiceException if there is a SOAP error.
 */
public WCTSoapCall(String host, int port, String service, String operation) throws ServiceException {
	this.endPoint = "http://" + host + ":" + port + service;
	this.operation = operation;
	
	Service serv = new Service();
    call = (Call) serv.createCall();
}
 
Example #13
Source File: GenericServiceEndpoint.java    From tomee with Apache License 2.0 3 votes vote down vote up
Call createCall() throws java.rmi.RemoteException {
        try {
            org.apache.axis.client.Call _call =
                (org.apache.axis.client.Call) service.createCall();
            if (super.maintainSessionSet) {
                _call.setMaintainSession(super.maintainSession);
            }
            if (super.cachedUsername != null) {
                _call.setUsername(super.cachedUsername);
            }
            if (super.cachedPassword != null) {
                _call.setPassword(super.cachedPassword);
            }
            if (super.cachedEndpoint != null) {
                _call.setTargetEndpointAddress(super.cachedEndpoint);
            }
            if (super.cachedTimeout != null) {
                _call.setTimeout(super.cachedTimeout);
            }
            if (super.cachedPortName != null) {
                _call.setPortName(super.cachedPortName);
            }
            java.util.Enumeration keys = super.cachedProperties.keys();
            while (keys.hasMoreElements()) {
                java.lang.String key = (java.lang.String) keys.nextElement();
                _call.setProperty(key, super.cachedProperties.get(key));
            }
            // All the type mapping information is registered
            // when the first call is made.
            // The type mapping information is actually registered in
            // the TypeMappingRegistry of the service, which
            // is the reason why registration is only needed for the first call.
            //TODO figure out if this can be done during deployment!
//            synchronized (this) {
//                if (firstCall()) {
//                    // must set encoding style before registering serializers
//                    //TODO these constants probably need to be parameters of GSE.
//                    _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
////                    _call.setEncodingStyle(org.apache.axis.Constants.URI_SOAP11_ENC);
//                    //override unsigned long mapping
//                    _call.registerTypeMapping(BigInteger.class,
//                            Constants.XSD_UNSIGNEDLONG,
//                            new SimpleSerializerFactory(BigInteger.class, Constants.XSD_UNSIGNEDLONG),
//                            new SimpleDeserializerFactory(BigInteger.class, Constants.XSD_UNSIGNEDLONG));
//                    _call.registerTypeMapping(URI.class,
//                            Constants.XSD_ANYURI,
//                            new SimpleSerializerFactory(URI.class, Constants.XSD_ANYURI),
//                            new SimpleDeserializerFactory(URI.class, Constants.XSD_ANYURI));
//                    for (Iterator iterator = typeInfo.iterator(); iterator.hasNext();) {
//                        TypeInfo info = (TypeInfo) iterator.next();
//                        _call.registerTypeMapping(info.getClazz(), info.getqName(), info.getSerFactoryClass(), info.getDeserFactoryClass(), false);
//                    }
//                }
//            }
            return _call;
        } catch (java.lang.Throwable t) {
            throw new org.apache.axis.AxisFault("Failure trying to get the Call object", t);
        }
    }