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; }