Esempio n. 1
0
  private XMLizable bind(XmlInputStream xin, QName responseElement, Class responseType)
      throws IOException, ConnectionException {

    readSoapEnvelopeStart(xin);

    xin.peekTag();
    typeMapper.verifyTag(
        responseElement.getNamespaceURI(),
        responseElement.getLocalPart(),
        xin.getNamespace(),
        xin.getName());

    // todo: change responseElement to typeInfo.
    TypeInfo info =
        new TypeInfo(
            responseElement.getNamespaceURI(),
            responseElement.getLocalPart(),
            null,
            null,
            1,
            1,
            true);

    XMLizable result = (XMLizable) typeMapper.readObject(xin, info, responseType);
    readSoapEnvelopeEnd(xin);
    return result;
  }
Esempio n. 2
0
  private void readSoapHeader(XmlInputStream xin) throws IOException, ConnectionException {
    while (!headerEndTag(xin)) {
      xin.peekTag();

      if (xin.getEventType() == XmlInputStream.START_TAG) {
        QName tag = new QName(xin.getNamespace(), xin.getName());

        Class headerType = (knownHeaders != null) ? knownHeaders.get(tag) : null;

        if (headerType != null) {
          TypeInfo info = new TypeInfo(xin.getNamespace(), xin.getName(), null, null, 1, 1, true);
          XMLizable result = (XMLizable) typeMapper.readObject(xin, info, headerType);
          if (connection != null) {
            setHeader(tag, headerType, result);
          }
        } else {
          throw new ConnectionException("Unrecognized header: " + tag.toString());
        }
      }
    }
    xin.next();
  }
Esempio n. 3
0
  private ConnectionException parseDetail(XmlInputStream xin, QName faultCode, String faultstring)
      throws IOException, ConnectionException {

    ConnectionException e;
    xin.nextTag(); // consume <detail>
    xin.peekTag(); // move to the body of <detail>

    if (xin.getEventType() == XmlInputStream.END_TAG) { // check for empty detail element
      throw new SoapFaultException(faultCode, faultstring);
    }

    TypeInfo info = new TypeInfo(null, null, null, null, 1, 1, true);

    try {
      e = (ConnectionException) typeMapper.readObject(xin, info, ConnectionException.class);
      if (e instanceof SoapFaultException) {
        ((SoapFaultException) e).setFaultCode(faultCode);
        if (faultstring != null
            && (faultstring.contains("Session timed out")
                || faultstring.contains("Session not found")
                || faultstring.contains("Illegal Session"))
            && "INVALID_SESSION_ID".equals(faultCode.getLocalPart())) {
          e = new SessionTimedOutException(faultstring, e);
        }
      }
    } catch (ConnectionException ce) {
      throw new ConnectionException(
          "Failed to parse detail: " + xin + " due to: " + ce, ce.getCause());
    }

    xin.nextTag(); // consume </detail>
    if (!"detail".equals(xin.getName())) {
      throw new ConnectionException("Failed to find </detail>");
    }

    return e;
  }