Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] XOM Object

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Brian Stechly <bstechly AT disk.com>
  • To: XOM API for Processing XML with Java <xom-interest AT lists.ibiblio.org>
  • Subject: Re: [XOM-interest] XOM Object
  • Date: Mon, 4 Nov 2013 12:17:52 -0600

Exception being thrown is:

Server sent invalid output without the expected content.
java.lang.NullPointerException


XML in question is:
<sObject xsi:type="sf:CampaignMember"
xmlns:sf="urn:sobject.enterprise.soap.sforce.com">
<sf:Id>00vi00000071B8rAAE</sf:Id>


I have tried several variations including those below (exception is always
thrown on the Element resSfIdA line):
Element resSObjectA =
aNotification.getFirstChildElement("sObject","urn:sobject.enterprise.soap.sforce.com");

Element resSfIdA =
resSObjectA.getFirstChildElement("sf:Id","urn:sobject.enterprise.soap.sforce.com");
System.out.print("\n Id:"); //+ resSfIdA.getValue());

Element resSObjectA =
aNotification.getFirstChildElement("sObject","urn:sobject.enterprise.soap.sforce.com");

Element resSfIdA = resSObjectA.getFirstChildElement("sf:Id");
System.out.print("\n Id:"); //+ resSfIdA.getValue());

Element resSObjectA = aNotification.getFirstChildElement("sObject");
Element resSfIdA = resSObjectA.getFirstChildElement("sf:Id");
System.out.print("\n Id:"); //+ resSfIdA.getValue());


FWIW, I ran the ElementListing code from the xom site:

soapenv:Envelope
soapenv:Body
notifications
OrganizationId
ActionId
SessionId
EnterpriseUrl
PartnerUrl
Notification
Id
sObject
sf:Id
sf:CampaignId
sf:Campaign_Member_Invitation_Code__c
sf:SOAP_Address__c
sf:SOAP_City__c
sf:SOAP_First_Name__c
sf:SOAP_Last_Name__c
sf:SOAP_Postal_Code__c
sf:SOAP_State__c
sf:School_Name__c
sf:Status



In summary, using XOM I can parse all the elements prior to the sObject..
Once I hit the sObject and the elements within it I get errors.

Would appreciate any advice/guidance.

Thanks!
Brian






-----Original Message-----
From: xom-interest-bounces AT lists.ibiblio.org
[mailto:xom-interest-bounces AT lists.ibiblio.org] On Behalf Of Brian Stechly
Sent: Friday, November 01, 2013 1:22 PM
To: xom-interest AT lists.ibiblio.org
Subject: [XOM-interest] XOM SOAP - sObject Simple question but I cannot find
an example

Hi,

I have been working on this simple code for days and am hoping somebody can
point me in the right direction. I cannot get the sObject and it's children
to parse correctly in the following:



public static Document XML_SOAP_Data(InputStream xml_in) {
try {
Builder builder = new Builder();
Document response = builder.build(xml_in);

/* response we are expecting

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
<soapenv:Body>
<notifications xmlns="http://soap.someURL.com/out";>
<OrganizationId>00Di0000000H88xEAC</OrganizationId>
<ActionId>04ki00000004FCuAAM</ActionId>
<SessionId xsi:nil="true"/>

<EnterpriseUrl>https://na15.salesomeurl.com/services/Soap/c/29.0/00Di0000000H88x</EnterpriseUrl>

<PartnerUrl>https://na15.salesomeurl.com/services/Soap/u/29.0/00Di0000000H88x</PartnerUrl>
<Notification>
<Id>04li00000017ikLAAQ</Id>
<sObject xsi:type="sf:CampaignMember"
xmlns:sf="urn:sobject.enterprise.soap.someurl.com">
<sf:Id>00vi00000071B8rAAE</sf:Id>
<sf:CampaignId>701i0000000EQMBAA4</sf:CampaignId>
<sf:SOAP_City__c>Washington</sf:SOAP_City__c>
<sf:SOAP_First_Name__c>Lisa Test-C</sf:SOAP_First_Name__c>
<sf:SOAP_Last_Name__c>Rossi</sf:SOAP_Last_Name__c>
<sf:SOAP_Postal_Code__c>20007-3117</sf:SOAP_Postal_Code__c>
<sf:SOAP_State__c>DC</sf:SOAP_State__c>
<sf:SOAP_Street__c>3133 &apos;O&apos; Street NW</sf:SOAP_Street__c>
<sf:School_Name__c>[not provided]</sf:School_Name__c>
<sf:Status>Not Sent</sf:Status>
</sObject>
</Notification>
</notifications>
</soapenv:Body>
</soapenv:Envelope>

*/
Element responseEnvelope =
response.getRootElement();
Element responseBody =
responseEnvelope.getFirstChildElement("Body","http://schemas.xmlsoap.org/soap/envelope/";);
Element fault =
responseBody.getFirstChildElement("Fault",
"http://schemas.xmlsoap.org/soap/envelope/";);
if (fault == null) { // no fault
Element resNotifications =
responseBody.getFirstChildElement("notifications",
"http://soap.someURL.com/out";);
Elements
resOrganizationId = resNotifications.getChildElements("OrganizationId",
"http://soap.someURL.com/out";);
Elements
resActionId = resNotifications.getChildElements("ActionId",
"http://soap.someURL.com/out";);
Elements
resSessionId = resNotifications.getChildElements("SessionId",
"http://soap.someURL.com/out";);
Elements
resEnterpriseUrl = resNotifications.getChildElements("EnterpriseUrl",
"http://soap.someURL.com/out";);
Elements
resPartnerUrl = resNotifications.getChildElements("PartnerUrl",
"http://soap.someURL.com/out";);
Elements
resNotification = resNotifications.getChildElements("Notification",
"http://soap.someURL.com/out";);
Element aNotification
= null;
for (int i =
0; i < resNotification.size(); i++) {

System.out.println("\n NEW Notification \n");

aNotification = resNotification.get(i); System.out.println("\n 1 \n");

Element resId = aNotification.getFirstChildElement("Id",
"http://soap.someURL.com/out";); //this works

// ! This is where I am having the issue ! //
// <sObject xsi:type="sf:CampaignMember"
xmlns:sf="urn:sobject.enterprise.soap.someurl.com">
// <sf:Id>00vi00000071B8rAAE</sf:Id>


Element resSObject = aNotification.getFirstChildElement("sObject",
"urn:sobject.enterprise.soap.someurl.com");


//Have tried with and without the line below

resSObject.addNamespaceDeclaration("sf",
"urn:sobject.enterprise.soap.someurl.com");


Element resSfId =
resSObject.getFirstChildElement("sf:Id",
"urn:sobject.enterprise.soap.someurl.com");



// ! Trying to get the sObject and child above to parse ! //




Thanks!

_______________________________________________
XOM-interest mailing list
XOM-interest AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/xom-interest




Archive powered by MHonArc 2.6.24.

Top of Page