Search in sources :

Example 1 with ParameterDesc

use of org.apache.axis.description.ParameterDesc in project tomee by apache.

the class ServiceEndpointMethodInterceptor method putInHolders.

private void putInHolders(Map outputParameters, Object[] objects, List parameterDescs) throws JavaUtils.HolderException {
    for (int i = 0; i < objects.length; i++) {
        Object parameter = objects[i];
        ParameterDesc parameterDesc = (ParameterDesc) parameterDescs.get(i);
        if ((parameterDesc.getMode() == ParameterDesc.INOUT) || (parameterDesc.getMode() == ParameterDesc.OUT)) {
            Object returned = outputParameters.get(parameterDesc.getQName());
            if (returned instanceof Holder) {
                //TODO this must be a bug somewhere!!!!
                returned = JavaUtils.getHolderValue(returned);
            }
            JavaUtils.setHolderValue(parameter, returned);
        }
    }
}
Also used : ParameterDesc(org.apache.axis.description.ParameterDesc) Holder(javax.xml.rpc.holders.Holder)

Example 2 with ParameterDesc

use of org.apache.axis.description.ParameterDesc in project tomee by apache.

the class AxisWsContainerTest method testInvokeSOAP.

public void testInvokeSOAP() throws Exception {
    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    JavaServiceDesc serviceDesc = new JavaServiceDesc();
    serviceDesc.setEndpointURL("http://127.0.0.1:8080/axis/services/echo");
    //serviceDesc.setWSDLFile(portInfo.getWsdlURL().toExternalForm());
    serviceDesc.setStyle(Style.RPC);
    serviceDesc.setUse(Use.ENCODED);
    TypeMappingRegistryImpl tmr = new TypeMappingRegistryImpl();
    tmr.doRegisterFromVersion("1.3");
    TypeMapping typeMapping = tmr.getOrMakeTypeMapping(serviceDesc.getUse().getEncoding());
    serviceDesc.setTypeMappingRegistry(tmr);
    serviceDesc.setTypeMapping(typeMapping);
    OperationDesc op = new OperationDesc();
    op.setName("echoString");
    op.setStyle(Style.RPC);
    op.setUse(Use.ENCODED);
    Class beanClass = EchoBean.class;
    op.setMethod(beanClass.getMethod("echoString", String.class));
    ParameterDesc parameter = new ParameterDesc(new QName("http://ws.apache.org/echosample", "in0"), ParameterDesc.IN, typeMapping.getTypeQName(String.class), String.class, false, false);
    op.addParameter(parameter);
    serviceDesc.addOperationDesc(op);
    serviceDesc.getOperations();
    ReadOnlyServiceDesc sd = new ReadOnlyServiceDesc(serviceDesc);
    Class pojoClass = cl.loadClass("org.apache.openejb.server.axis.EchoBean");
    RPCProvider provider = new PojoProvider();
    SOAPService service = new SOAPService(null, provider, null);
    service.setServiceDescription(sd);
    service.setOption("className", "org.apache.openejb.server.axis.EchoBean");
    URL wsdlURL = new URL("http://fake/echo.wsdl");
    URI location = new URI(serviceDesc.getEndpointURL());
    Map wsdlMap = new HashMap();
    AxisWsContainer container = new AxisWsContainer(wsdlURL, service, wsdlMap, cl);
    InputStream in = cl.getResourceAsStream("echoString-req.txt");
    try {
        AxisRequest req = new AxisRequest(504, "text/xml; charset=utf-8", new ServletIntputStreamAdapter(in), HttpRequest.Method.GET, new HashMap<String, String>(), location, new HashMap<String, String>(), "127.0.0.1");
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        AxisResponse res = new AxisResponse("text/xml; charset=utf-8", "127.0.0.1", null, null, 8080, new ServletOutputStreamAdapter(out));
        req.setAttribute(WsConstants.POJO_INSTANCE, pojoClass.newInstance());
        container.onMessage(req, res);
        out.flush();
    //            log.debug(new String(out.toByteArray()));
    } finally {
        if (in != null) {
            try {
                in.close();
            } catch (IOException ignore) {
            // ignore
            }
        }
    }
}
Also used : ParameterDesc(org.apache.axis.description.ParameterDesc) HashMap(java.util.HashMap) TypeMappingRegistryImpl(org.apache.axis.encoding.TypeMappingRegistryImpl) RPCProvider(org.apache.axis.providers.java.RPCProvider) URI(java.net.URI) URL(java.net.URL) ServletIntputStreamAdapter(org.apache.openejb.server.httpd.ServletIntputStreamAdapter) JavaServiceDesc(org.apache.axis.description.JavaServiceDesc) SOAPService(org.apache.axis.handlers.soap.SOAPService) QName(javax.xml.namespace.QName) InputStream(java.io.InputStream) OperationDesc(org.apache.axis.description.OperationDesc) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) ServletOutputStreamAdapter(org.apache.openejb.server.httpd.ServletOutputStreamAdapter) TypeMapping(org.apache.axis.encoding.TypeMapping) HashMap(java.util.HashMap) Map(java.util.Map)

Example 3 with ParameterDesc

use of org.apache.axis.description.ParameterDesc in project tomee by apache.

the class ServiceEndpointMethodInterceptor method extractFromHolders.

private Object[] extractFromHolders(Object[] objects, List parameterDescs, int inParameterCount) throws JavaUtils.HolderException {
    if (objects.length != parameterDescs.size()) {
        throw new IllegalArgumentException("Mismatch parameter count: expected: " + parameterDescs.size() + ", actual: " + objects.length);
    }
    Object[] unwrapped = new Object[inParameterCount];
    int j = 0;
    for (int i = 0; objects != null && i < objects.length; i++) {
        Object parameter = objects[i];
        ParameterDesc parameterDesc = (ParameterDesc) parameterDescs.get(i);
        if (parameterDesc.getMode() == ParameterDesc.INOUT) {
            unwrapped[j++] = JavaUtils.getHolderValue(parameter);
        } else if (parameterDesc.getMode() == ParameterDesc.IN) {
            unwrapped[j++] = parameter;
        }
    }
    return unwrapped;
}
Also used : ParameterDesc(org.apache.axis.description.ParameterDesc)

Example 4 with ParameterDesc

use of org.apache.axis.description.ParameterDesc in project tomee by apache.

the class JavaServiceDescBuilder method buildParameterDesc.

private ParameterDesc buildParameterDesc(JaxRpcParameterInfo parameterInfo) throws OpenEJBException {
    byte mode = ParameterDesc.modeFromString(parameterInfo.mode.toString());
    boolean inHeader = parameterInfo.soapHeader && parameterInfo.mode.isIn();
    boolean outHeader = parameterInfo.soapHeader && parameterInfo.mode.isOut();
    Class<?> javaType;
    try {
        javaType = classLoader.loadClass(parameterInfo.javaType);
    } catch (ClassNotFoundException e) {
        throw new OpenEJBException("Unable to load parameter type " + parameterInfo.javaType);
    }
    ParameterDesc parameterDesc = new ParameterDesc(parameterInfo.qname, mode, parameterInfo.xmlType, javaType, inHeader, outHeader);
    return parameterDesc;
}
Also used : ParameterDesc(org.apache.axis.description.ParameterDesc) OpenEJBException(org.apache.openejb.OpenEJBException)

Example 5 with ParameterDesc

use of org.apache.axis.description.ParameterDesc in project tomee by apache.

the class JavaServiceDescBuilder method buildFaultDesc.

private FaultDesc buildFaultDesc(JaxRpcFaultInfo faultInfo) throws OpenEJBException {
    FaultDesc faultDesc = new FaultDesc(faultInfo.qname, faultInfo.javaType, faultInfo.xmlType, faultInfo.complex);
    ArrayList<ParameterDesc> parameters = new ArrayList<ParameterDesc>();
    for (JaxRpcParameterInfo parameterInfo : faultInfo.parameters) {
        ParameterDesc parameterDesc = buildParameterDesc(parameterInfo);
        parameters.add(parameterDesc);
    }
    faultDesc.setParameters(parameters);
    return faultDesc;
}
Also used : ParameterDesc(org.apache.axis.description.ParameterDesc) JaxRpcParameterInfo(org.apache.openejb.server.axis.assembler.JaxRpcParameterInfo) ArrayList(java.util.ArrayList) FaultDesc(org.apache.axis.description.FaultDesc)

Aggregations

ParameterDesc (org.apache.axis.description.ParameterDesc)6 FaultDesc (org.apache.axis.description.FaultDesc)2 OperationDesc (org.apache.axis.description.OperationDesc)2 OpenEJBException (org.apache.openejb.OpenEJBException)2 JaxRpcParameterInfo (org.apache.openejb.server.axis.assembler.JaxRpcParameterInfo)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Method (java.lang.reflect.Method)1 URI (java.net.URI)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 QName (javax.xml.namespace.QName)1 Holder (javax.xml.rpc.holders.Holder)1 JavaServiceDesc (org.apache.axis.description.JavaServiceDesc)1 TypeMapping (org.apache.axis.encoding.TypeMapping)1 TypeMappingRegistryImpl (org.apache.axis.encoding.TypeMappingRegistryImpl)1 SOAPService (org.apache.axis.handlers.soap.SOAPService)1