示例#1
0
  private void readSoapEnvelopeEnd(XmlInputStream xin) throws IOException, ConnectionException {
    xin.nextTag();
    typeMapper.verifyTag(Constants.SOAP_ENVELOPE_NS, "Body", xin.getNamespace(), xin.getName());

    xin.nextTag();
    typeMapper.verifyTag(Constants.SOAP_ENVELOPE_NS, "Envelope", xin.getNamespace(), xin.getName());
  }
示例#2
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;
  }
示例#3
0
  private ConnectionException createException(XmlInputStream xin)
      throws IOException, ConnectionException {
    readSoapEnvelopeStart(xin);

    xin.nextTag();
    typeMapper.verifyTag(Constants.SOAP_ENVELOPE_NS, "Fault", xin.getNamespace(), xin.getName());

    xin.nextTag();
    if (!"faultcode".equals(xin.getName())) {
      throw new ConnectionException("Unable to find 'faultcode' in SOAP:Fault");
    }
    String faultCodeStr = xin.nextText();
    String prefix = TypeMapper.getPrefix(faultCodeStr);
    String name = TypeMapper.getType(faultCodeStr);
    String namespace = xin.getNamespace(prefix);
    QName faultCode = new QName(namespace, name);

    xin.nextTag();
    if (!"faultstring".equals(xin.getName())) {
      throw new ConnectionException("Unable to find 'faultstring' in SOAP:Fault");
    }
    String faultstring = xin.nextText();

    ConnectionException e;
    xin.peekTag();
    if ("detail".equals(xin.getName())) {
      e = parseDetail(xin, faultCode, faultstring);
    } else {
      e = new SoapFaultException(faultCode, faultstring);
    }

    xin.nextTag();
    typeMapper.verifyTag(Constants.SOAP_ENVELOPE_NS, "Fault", xin.getNamespace(), xin.getName());

    readSoapEnvelopeEnd(xin);
    return e;
  }