Exemple #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());
  }
Exemple #2
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;
  }
Exemple #3
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();
  }
Exemple #4
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;
  }
Exemple #5
0
 private boolean isHeader(XmlInputStream xin) {
   return Constants.SOAP_ENVELOPE_NS.equals(xin.getNamespace()) && "Header".equals(xin.getName());
 }