1

Please check below code.

i got below error

java.lang.NullPointerException: Attempt to invoke virtual method 'void java.lang.Throwable.printStackTrace()' on a null object reference

check my code

@Override
public void Retrieve(String logicalName, UUID id, @NonNull ColumnSet columnSet, final Callback<Entity> callback) {
    StringBuilder content = new StringBuilder();
    content.append(GetEnvelopeHeader());
    content.append("<s:Body>");
    content.append("<d:Retrieve>");
    content.append("<d:entityName>" + Utils.encodeXML(logicalName) + "</d:entityName>");
    content.append("<d:id>" + Utils.encodeXML(id.toString()) + "</d:id>");
    content.append(Utils.objectToXml(columnSet, "d:columnSet", true));
    content.append("</d:Retrieve>");
    content.append("</s:Body>");
    content.append("</s:Envelope>");

    SoapEndpoint.Soap(SoapActions.RETRIEVE, new TypedString(content.toString()), new Callback<String>() {

        @Override
        public void success(String xml, Response response) {
            Entity entity = null;

            try {
                XmlPullParser parser = Xml.newPullParser();
                parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
                parser.setInput(new ByteArrayInputStream(xml.getBytes()), null);
                do {
                    parser.next();
                } while(!parser.getName().equals("RetrieveResult"));
                parser.require(XmlPullParser.START_TAG,    "http://schemas.microsoft.com/xrm/2011/Contracts/Services", "RetrieveResult");

                entity = Entity.loadFromXml(parser);
            }
            catch(Exception ex) {
                ex.getCause().printStackTrace();
            }

            if (entity != null) {
                callback.success(entity, response);
            }
        }

        @Override
        public void failure(RetrofitError error) {
            callback.failure(error);
        }
    });
}
Anil Kanani
  • 260
  • 2
  • 19
  • Try with ex.printStackTrace(). Original answer/Suggested reason [here](http://stackoverflow.com/questions/6158817/exception-getcause-returning-null-when-trying-to-find-the-source-of-an-excepti) – Raghavendra Jun 06 '16 at 06:24
  • Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference – Anil Kanani Jun 06 '16 at 06:40
  • Check parser.getName() is null/not? – Raghavendra Jun 06 '16 at 06:45

0 Answers0