Package org.apache.wsif

Examples of org.apache.wsif.WSIFException


                parts = new Vector();
                for (Iterator i = partNames.iterator(); i.hasNext();) {
                    String partName = (String) i.next();
                    Part part = input.getMessage().getPart(partName);
                    if (part == null) {
                        throw new WSIFException(
                            "no input part named "
                                + partName
                                + " for binding operation "
                                + getName());
                    }
                    parts.add(part);
                }
            } else {
                parts = input.getMessage().getOrderedParts(null);
            }
            int count = parts.size();
            names = new String[count];
            types = new Class[count];

            // get parts in correct order
            for (int i = 0; i < count; ++i) {
                Part part = (Part) parts.get(i);
                names[i] = part.getName();
                QName partType = part.getTypeName();
                if (partType == null)
                    partType = part.getElementName();
                if (partType == null) {
                    throw new WSIFException(
                        "part " + names[i] + " must have type name declared");
                }

                org.apache.soap.util.xml.QName qname =
                    new org.apache.soap.util.xml.QName(
                        partType.getNamespaceURI(),
                        partType.getLocalPart());
                try {
                    types[i] = (Class) mapOfUserTypes.get(qname);
                } catch (Throwable ignored) {
                    Trc.ignoredException(ignored);
                }
                if (types[i] == null) {
                    try {
                        types[i] =
                            (Class) smr.queryJavaType(
                                qname,
                                inputEncodingStyle);
                    } catch (Throwable exn) {
                        if (types[i] == null) {
                            try {
                                String packageName =
                                    WSIFUtils.getPackageNameFromNamespaceURI(
                                        qname.getNamespaceURI());
                                String className =
                                    WSIFUtils.getJavaClassNameFromXMLName(
                                        qname.getLocalPart());
                                Class inputClass = null;
                                try {
                                    inputClass =
                                    Class.forName(
                                        packageName + "." + className,
                                        true,
                                        Thread
                                            .currentThread()
                                            .getContextClassLoader());
                                } catch (ClassNotFoundException exn5) {
                                    inputClass =
                                        Class.forName(
                                            packageName
                                                + "."
                                                + className
                                                + "Element",
                                            true,
                                            Thread
                                                .currentThread()
                                                .getContextClassLoader());
                                }
                                types[i] = inputClass;
                                if ("literal".equals(inputUse)) {
                                  smr.mapTypes("literal", qname, inputClass, partSer, partSer);
                                } else {
                                smr.mapTypes(
                                    Constants.NS_URI_SOAP_ENC,
                                    qname,
                                    inputClass,
                                    beanSer,
                                    beanSer);
                                }
                                mapSubtypes(inputClass, beanSer, partSer, smr, inputUse);
                            } catch (ClassNotFoundException exn1) {
                              Trc.ignoredException(exn1);
                            }
                        }
                    }

                }
            }
        } else {
            names = new String[0];
            types = new Class[0];
        }

        // now prepare return value
        Output output = operation.getOutput();
        if (output != null) {
            Part returnPart = null;
            if (returnName != null) {
                returnPart = output.getMessage().getPart(returnName);
                if (returnPart == null) {
                    throw new WSIFException(
                        "no output part named "
                            + returnName
                            + " for bining operation "
                            + getName());
                }
View Full Code Here


            // some runtime param validity check

            if (value != null
                && !types[i].isPrimitive()
                && !(types[i].isAssignableFrom(value.getClass()))) {
                throw new WSIFException(
                    "value "
                        + value
                        + " has unexpected type "
                        + value.getClass()
                        + " instead of "
                        + types[i]);
            }

      if (inJmsProps.containsKey(names[i]) && st != null) {
        String name = (String) (inJmsProps.get(names[i]));
        if (!timeoutProperty(st, name, value)) {
                   ((SOAPJMSConnection) st).setJmsProperty(
              name,
              value);
        }
      } else {
                Parameter param =
                    new Parameter(
                        names[i],
                        types[i],
                        value,
                        inputEncodingStyle);
                params.addElement(param);
            }
        }

        call.setParams(params);

        setTransportContext(st);

        setCallContext(call);

        // invoke the operation through ApacheSOAP
        Response resp;
        boolean respOK = true;
        URL locationUri = portInstance.getEndPoint();
        if ( locationUri != null && !isHostInNonProxyProperty( locationUri ) ) {
           setSOAPProxy( st );
        }

        Trc.event(
            this,
            "Invoking operation ",
            getName(),
            " on ",
            locationUri,
            " call object ",
            call);

        try {
            resp = call.invoke(locationUri, getSoapActionURI());
        } catch (SOAPException e) {
            Trc.exception(e);

            // Log message
            MessageLogger.log("WSIF.0005E", "ApacheSOAP", getName());

            throw new WSIFException(
                "SOAPException: " + e.getFaultCode() + e.getMessage(),
                e);
        }

        Trc.event(this, "Operation returned ", resp);
View Full Code Here

            } else if (ee instanceof JMSPropertyValue) {
                JMSPropertyValue propVal = (JMSPropertyValue) ee;
   
                String name = propVal.getName();
                if (name == null || name.length() == 0)
                    throw new WSIFException("jms:propertyValue found without a name");
   
                QName type = propVal.getType();
                if (type == null)
                    throw new WSIFException(
                        "jms:propertyValue " + name + " did not have a type");
                if (type.getNamespaceURI() == null || type.getLocalPart() == null)
                    throw new WSIFException(
                        "jms:propertyValue " + name + " has a badly formed type");
   
                String value = propVal.getValue();
                if (value == null || value.length() == 0)
                    throw new WSIFException(
                        "jms:propertyValue " + name + " did not have a value");
   
                TypeMapping tm = (TypeMapping) (simpleTypeReg.get(type));
                if (tm == null || tm.javaType == null)
                    throw new WSIFException(
                        "jms:propertyValue "
                            + name
                            + " had a type that was "
                            + "unknown or was not a simple type");
   
                Class javaClass = null;
                try {
                    javaClass =
                        Class.forName(
                            tm.javaType,
                            true,
                            Thread.currentThread().getContextClassLoader());
                } catch (ClassNotFoundException cce) {
                    Trc.exception(cce);
                    throw new WSIFException(
                        "Unexpected ClassNotFoundException when processing "
                            + "jms:propertyValue "
                            + name
                            + ". Could not convert the type to a java class. "
                            + cce);
                }
   
                Object obj = null;
                try {
                    if (javaClass.equals(String.class))
                        obj = value;
                    else if (javaClass.equals(Integer.class))
                        obj = new Integer(value);
                    else if (javaClass.equals(Boolean.class))
                        obj = new Boolean(value);
                    else if (javaClass.equals(Byte.class))
                        obj = new Byte(value);
                    else if (javaClass.equals(Double.class))
                        obj = new Double(value);
                    else if (javaClass.equals(Float.class))
                        obj = new Float(value);
                    else if (javaClass.equals(Long.class))
                        obj = new Long(value);
                    else if (javaClass.equals(Short.class))
                        obj = new Short(value);
                    else
                        throw new WSIFException(
                            "jms:propertyValue " + name + " had an invalid type");
                } catch (NumberFormatException nfe) {
                    Trc.exception(nfe);
                    throw new WSIFException(
                        "jms:propertyValue "
                            + name
                            + " a value that could not "
                            + "be converted into the specified type. Caught NumberFormatException. "
                            + nfe);
View Full Code Here

            // receive response envelope
            env = msg.receiveEnvelope();
        } catch (SOAPException exn) {
            Trc.exception(exn);
            WSIFException e =
                new WSIFException("SOAP Exception: " + exn.getMessage());
            e.setTargetException(exn);
            throw e;
        }

        Trc.event(this, "Returned from operation, envelope ", env);
View Full Code Here

            contextCopy = (WSIFMessage) getWSIFPort().getContext().clone();
          } else {
          contextCopy = (WSIFMessage) this.context.clone();
          }
    } catch (CloneNotSupportedException e) {
        throw new WSIFException(
            "CloneNotSupportedException cloning context", e);
    }
        Trc.exit(contextCopy);
      return contextCopy;
    }
View Full Code Here

    abstract protected Operation getOperation() throws Exception;
   
    protected void close() throws WSIFException {
    Trc.entry(this);
        if (closed)
            throw new WSIFException("Cannot reuse a WSIFOperation to invoke multiple operations");
        closed = true;
        Trc.exit();
    }
View Full Code Here

        if (!prepared)
            prepare(input, null);

        if (!portInstance.supportsAsync()) {
            throw new WSIFException("asynchronous operations not available");
        }

        if ("document".equals(style)) {
            throw new WSIFException("docstyle asynchronous operations not implemented");
        }

        setAsyncOperation(true);
        setResponseHandler(handler);
        SOAPJMSConnection transport = (SOAPJMSConnection) getTransport();
View Full Code Here

     */
    private Response deserialiseResponseObject(Object msg)
        throws WSIFException {

        if (msg == null) {
            throw new WSIFException("null response to async send");
        }

        if (!(msg instanceof javax.jms.TextMessage)) {
            throw new WSIFException("response not a javax.jms.TextMessage");
        }

        HashMap mapOfUserTypes = new HashMap();
        SOAPMappingRegistry smr =
            WSIFPort_ApacheSOAP.createSOAPMappingRegistry(new Call());
         
        // clear port to ensure setupTypeMappings does something
        setDynamicWSIFPort( null );

        setupTypeMappings(mapOfUserTypes, smr);

        try {

            javax.jms.TextMessage m = (javax.jms.TextMessage) msg;
            String payloadStr = m.getText();

            // Get the response context.
            SOAPContext respCtx = new SOAPContext();
            respCtx.setRootPart(payloadStr, "text/xml");

            // Parse the incoming response stream.
            DocumentBuilder xdb = XMLParserUtils.getXMLDocBuilder();
            Document respDoc =
                xdb.parse(new InputSource(new StringReader(payloadStr)));
            Element payload = null;

            if (respDoc != null) {
                payload = respDoc.getDocumentElement();
            } else { //probably does not happen
                throw new SOAPException(
                    Constants.FAULT_CODE_CLIENT,
                    "Parsing error, response was:\n" + payloadStr);
            }

            // Unmarshall the response envelope.
            Envelope respEnv = Envelope.unmarshall(payload, respCtx);

            // Extract the response from the response envelope.
            Response resp = Response.extractFromEnvelope(respEnv, smr, respCtx);

            return resp;

        } catch (Exception ex) {
            Trc.exception(ex);
            throw new WSIFException(ex.getMessage());
        }
    }
View Full Code Here

        throws WSIFException {

        boolean respOK;

        if (resp == null) {
            throw new WSIFException("soap response is null");
        }

        if (resp.generatedFault()) {
            respOK = false;
            if (faultMsg != null) {
View Full Code Here

    private void populateOutMsgReturnPart(Response resp, WSIFMessage outMsg)
        throws WSIFException {
        if (outMsg != null && returnName != null) {
            Parameter retValue = resp.getReturnValue();
            if (retValue == null) {
                throw new WSIFException("return value not found in response message");
            }
            Object result = retValue.getValue();
            if (returnType != null) { // will be null for async responses
                if (!returnType.isPrimitive()
                    && result != null
                    && !(returnType.isAssignableFrom(result.getClass()))) {
                    throw new WSIFException(
                        "return value "
                            + result
                            + " has unexpected type "
                            + result.getClass()
                            + " instead of "
View Full Code Here

TOP

Related Classes of org.apache.wsif.WSIFException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.