• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Couldn't create XML document from String.

 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I tried to create a XML document from the below


<Response xmlns="urn:oasis:names:tc:SAML:2.0:protocol" Destination="https://optus--PHUB.cs5.my.salesforce.com?so=00DO00000051q90" ID="_6f37234dfd47fbda1108f439b3d655f4e4b1" InResponseTo="_2CAAAAVGAV-1eME8wTzAwMDAwMDAwMDAyAAAAxliRspPZxIEJbTkJslk0pWeSau3ZcFcjP3Ivaecf68tjX6a_VIh1t80Augu1e-ADqFEV-htJFTTCXI_vjXQyVnN16tgQKjjYsjgkYNh9z1ekTG8xw1FssvDfkZ9nNfKZcojaxQAqugzr8aadXB8-66PoaYRCr7H7yhWG943xS0mBOZSBbho6AZl8Tv5ByMebhmWPhTVW8_JPJ4hAij-lS4-NtY8AsWtowPdjTceoJ9Ye7yTAE1Rpzrm2tVWy8_f9yQ" IssueInstant="2015-11-10T06:49:37Z" Version="2.0">
<ns1:Issuer xmlns:ns1="urn:oasis:names:tc:SAML:2.0:assertion" Format="urn:oasis:names:tc:SAML:2.0:nameid-format:entity">https://st2.my.optus.com.au/SalesSSO</ns1:Issuer>;
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<ds:Reference URI="#_6f37234dfd47fbda1108f439b3d655f4e4b1">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>wp3kgQ5QQnnBTbzowVRIMJwc8mU=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>
V5iQGUOBSqqkp/3dA7BnBnts4hcod4Blkk1i5Jq+SrtMC/wkf6wBAIZ6MMo08hQ8gz3LbCQ0RYGq
+WHisrHDpA==
</ds:SignatureValue>
<ds:KeyInfo>
<ds:X509Data>
<ds:X509Certificate>
MIIDXjCCAwigAwIBAgIJAMJDTkGxtyLcMA0GCSqGSIb3DQEBBQUAMIGoMQswCQYDVQQGEwJBVTEY
MBYGA1UECBMPTmV3IFNvdXRoIFdhbGVzMQ8wDQYDVQQHEwZTeWRuZXkxDjAMBgNVBAoTBU9wdHVz
MQwwCgYDVQQLEwNQRUkxHDAaBgNVBAMTE3N0Mi5teS5vcHR1cy5jb20uYXUxMjAwBgkqhkiG9w0B
CQEWI3N0Mi5teS5vcHR1cy5jb20uYXVAbXkub3B0dXMuY29tLmF1MB4XDTE1MDYyMjA3NDYwN1oX
DTI1MDYxOTA3NDYwN1owgagxCzAJBgNVBAYTAkFVMRgwFgYDVQQIEw9OZXcgU291dGggV2FsZXMx
DzANBgNVBAcTBlN5ZG5leTEOMAwGA1UEChMFT3B0dXMxDDAKBgNVBAsTA1BFSTEcMBoGA1UEAxMT
c3QyLm15Lm9wdHVzLmNvbS5hdTEyMDAGCSqGSIb3DQEJARYjc3QyLm15Lm9wdHVzLmNvbS5hdUBt
eS5vcHR1cy5jb20uYXUwXDANBgkqhkiG9w0BAQEFAANLADBIAkEAunh6W/ve6eaijMH8bTvvIe3Q
747gIN0yM4j6hOu19EbldA8dfNzr1kyiIeWH5jdB513dZESGtVpfa0P5RmG4/wIDAQABo4IBETCC
AQ0wHQYDVR0OBBYEFIgdg6n7ovadSVOyX/EH47WTVAkNMIHdBgNVHSMEgdUwgdKAFIgdg6n7ovad
SVOyX/EH47WTVAkNoYGupIGrMIGoMQswCQYDVQQGEwJBVTEYMBYGA1UECBMPTmV3IFNvdXRoIFdh
bGVzMQ8wDQYDVQQHEwZTeWRuZXkxDjAMBgNVBAoTBU9wdHVzMQwwCgYDVQQLEwNQRUkxHDAaBgNV
BAMTE3N0Mi5teS5vcHR1cy5jb20uYXUxMjAwBgkqhkiG9w0BCQEWI3N0Mi5teS5vcHR1cy5jb20u
YXVAbXkub3B0dXMuY29tLmF1ggkAwkNOQbG3ItwwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUF
AANBAGo5euaeArQz4GAXVUBsEQX5xhm9sXjdbfTwkqFfVoK1+f9kg7E83+8uRK07lIc1cW+Ayk6L
KJRhzoRF0C1IQMc=
</ds:X509Certificate>
</ds:X509Data>
</ds:KeyInfo>
</ds:Signature>
<Status>
<StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"/>
</Status>
<ns2:Assertion xmlns:ns2="urn:oasis:names:tc:SAML:2.0:assertion" ID="_85912e208de500617d79e2f0d9a33954af65" IssueInstant="2015-11-10T06:49:37Z" Version="2.0">
<ns2:Issuer Format="urn:oasis:names:tc:SAML:2.0:nameid-format:entity">https://st2.my.optus.com.au/SalesSSO</ns2:Issuer><ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<ds:Reference URI="#_85912e208de500617d79e2f0d9a33954af65">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>shJheN2UhS/8VBXCcdBoMBwILgI=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>
NRG+4U2O52ZWHmUnE4FBSJbpDIg4wgxc6dltoPs9zVxKbgdZHOqUR+YF7Qi7kmDhXGBCkYNq47z6
JSNawtLMMQ==
</ds:SignatureValue>
<ds:KeyInfo>
<ds:X509Data>
<ds:X509Certificate>
MIIDXjCCAwigAwIBAgIJAMJDTkGxtyLcMA0GCSqGSIb3DQEBBQUAMIGoMQswCQYDVQQGEwJBVTEY
MBYGA1UECBMPTmV3IFNvdXRoIFdhbGVzMQ8wDQYDVQQHEwZTeWRuZXkxDjAMBgNVBAoTBU9wdHVz
MQwwCgYDVQQLEwNQRUkxHDAaBgNVBAMTE3N0Mi5teS5vcHR1cy5jb20uYXUxMjAwBgkqhkiG9w0B
CQEWI3N0Mi5teS5vcHR1cy5jb20uYXVAbXkub3B0dXMuY29tLmF1MB4XDTE1MDYyMjA3NDYwN1oX
DTI1MDYxOTA3NDYwN1owgagxCzAJBgNVBAYTAkFVMRgwFgYDVQQIEw9OZXcgU291dGggV2FsZXMx
DzANBgNVBAcTBlN5ZG5leTEOMAwGA1UEChMFT3B0dXMxDDAKBgNVBAsTA1BFSTEcMBoGA1UEAxMT
c3QyLm15Lm9wdHVzLmNvbS5hdTEyMDAGCSqGSIb3DQEJARYjc3QyLm15Lm9wdHVzLmNvbS5hdUBt
eS5vcHR1cy5jb20uYXUwXDANBgkqhkiG9w0BAQEFAANLADBIAkEAunh6W/ve6eaijMH8bTvvIe3Q
747gIN0yM4j6hOu19EbldA8dfNzr1kyiIeWH5jdB513dZESGtVpfa0P5RmG4/wIDAQABo4IBETCC
AQ0wHQYDVR0OBBYEFIgdg6n7ovadSVOyX/EH47WTVAkNMIHdBgNVHSMEgdUwgdKAFIgdg6n7ovad
SVOyX/EH47WTVAkNoYGupIGrMIGoMQswCQYDVQQGEwJBVTEYMBYGA1UECBMPTmV3IFNvdXRoIFdh
bGVzMQ8wDQYDVQQHEwZTeWRuZXkxDjAMBgNVBAoTBU9wdHVzMQwwCgYDVQQLEwNQRUkxHDAaBgNV
BAMTE3N0Mi5teS5vcHR1cy5jb20uYXUxMjAwBgkqhkiG9w0BCQEWI3N0Mi5teS5vcHR1cy5jb20u
YXVAbXkub3B0dXMuY29tLmF1ggkAwkNOQbG3ItwwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUF
AANBAGo5euaeArQz4GAXVUBsEQX5xhm9sXjdbfTwkqFfVoK1+f9kg7E83+8uRK07lIc1cW+Ayk6L
KJRhzoRF0C1IQMc=
</ds:X509Certificate>
</ds:X509Data>
</ds:KeyInfo>
</ds:Signature>
<ns2:Subject>
<ns2:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">User2</ns2:NameID>
<ns2:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
<ns2:SubjectConfirmationData InResponseTo="_2CAAAAVGAV-1eME8wTzAwMDAwMDAwMDAyAAAAxliRspPZxIEJbTkJslk0pWeSau3ZcFcjP3Ivaecf68tjX6a_VIh1t80Augu1e-ADqFEV-htJFTTCXI_vjXQyVnN16tgQKjjYsjgkYNh9z1ekTG8xw1FssvDfkZ9nNfKZcojaxQAqugzr8aadXB8-66PoaYRCr7H7yhWG943xS0mBOZSBbho6AZl8Tv5ByMebhmWPhTVW8_JPJ4hAij-lS4-NtY8AsWtowPdjTceoJ9Ye7yTAE1Rpzrm2tVWy8_f9yQ" NotOnOrAfter="2015-11-10T06:51:07Z" Recipient="https://optus--PHUB.cs5.my.salesforce.com?so=00DO00000051q90"/>
</ns2:SubjectConfirmation>
</ns2:Subject>
<ns2:Conditions NotBefore="2015-11-10T06:49:07Z" NotOnOrAfter="2015-11-10T06:51:07Z">
<ns2:AudienceRestriction>
<ns2:Audience>https://optus--PHUB.cs5.my.salesforce.com</ns2:Audience>;
</ns2:AudienceRestriction>
</ns2:Conditions>
<ns2:AuthnStatement AuthnInstant="2015-11-10T06:49:36Z" SessionIndex="+6ZUXHQlDkZBYAzhni2erVnxn2E=WOO1OA==" SessionNotOnOrAfter="2015-11-10T06:51:07Z">
<ns2:AuthnContext>
<ns2:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:Password</ns2:AuthnContextClassRef>
</ns2:AuthnContext>
</ns2:AuthnStatement>
<ns2:AttributeStatement>
<ns2:Attribute Name="Application_Role" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified">
<ns2:AttributeValue>SOS</ns2:AttributeValue>
</ns2:Attribute>
<ns2:Attribute Name="LoginChannel" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified">
<ns2:AttributeValue>Internal</ns2:AttributeValue>
</ns2:Attribute>
</ns2:AttributeStatement>
</ns2:Assertion>
</Response>





When i tried to get the NodeList it throws me null pointer exception.

Please suggest me where i have mistaken.

Thanks in advance.
 
Trailboss
Posts: 23778
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you sure you meant to post this in the ranch office forum?
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you show us the stack trace?
 
syruss kumar
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry Paul Wrongly posted in this forum.

It should be in Java-XML Technology

Hi Rob,

Thanks a lot for your response.

I found the issue.

NodeList nodeLst=(NodeList) doc.getAttributes();

The above highlighted line should be as below

NodeList nodeLst=(NodeList) doc.getChildNodes();

Its working fine now.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, that's right. The document node doesn't have any attributes (it's the parent of the document's root node, which does have attributes) and so the getAttributes() method returns null.

(It should return an empty list rather than the user-unfriendly null reference, but it doesn't, that's just the way it is.)
 
I want my playground back. Here, I'll give you this tiny ad for it:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic