Regular Contributor.. Curtis Owings Regular Contributor..
Regular Contributor..
537 views

Some configs stored as Base64 on HPNA 10.21.05

Jump to solution

We are begining to use more of the HPNA SOAP API functionality.  When executing

http://hpna-host/soap/show_device_config

... in some cases I'm getting encoded Base64 results which are of course unreadable without some extra handling.  I've never decoded Base64 before (I'm using Python 3.6)--I'm sure I can figure it out, but why is it happening and is there some way I can turn it off?

RETURN ENV:

SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
   <SOAP-ENV:Header/>
   <SOAP-ENV:Body>
      <nas:show_device_configResponse xmlns:nas="http://hp.com/nas/10/20">
         <nas:Result>
            <nas:Status>200</nas:Status>
            <nas:Text xsi:type="SOAP-ENC:base64" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Some configs stored as Base64 on HPNA 10.21.05

Jump to solution

Hi @Curtis Owings,

the reason for that is this:

NA will encode the SOAP message if it contain control characters.

 

This is not an application limitation but from the XML documents since they cannot include any control characters (ASCII codes 0 through 31) except tabs, carriage returns, and line feeds.

 

This limitation includes both the straight occurrences of the characters and their encoded form as character references, such as &#x04;.

 

Further, carriage returns are always converted to line feeds by XML processors.

 

It is important to keep in mind that not all characters you can put in a string variable in a programming language can be represented in XML documents. If not careful, this situation can lead to unexpected runtime errors.

 

In addition, we recommend using the PERL API since it will always decode the text for you.

as a recommendation is actually that you can program a function that decode the soap call response.

Any text that contains a character other than the below (where C is a character in java) will be encoded to base 64

c > 31 || c == '\t' || c == '\n' || c == '\r'

Pedro A. Batista
Customer Support Engineer

If you find that this or any other post resolves your issue, please be sure to mark it as an accepted solution.
If you are satisfied with anyone’s response please remember to give them a KUDOS by clicking on the THUMB at the bottom left of the post and show your appreciation.
Tags (2)
3 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Some configs stored as Base64 on HPNA 10.21.05

Jump to solution

Hi @Curtis Owings,

the reason for that is this:

NA will encode the SOAP message if it contain control characters.

 

This is not an application limitation but from the XML documents since they cannot include any control characters (ASCII codes 0 through 31) except tabs, carriage returns, and line feeds.

 

This limitation includes both the straight occurrences of the characters and their encoded form as character references, such as &#x04;.

 

Further, carriage returns are always converted to line feeds by XML processors.

 

It is important to keep in mind that not all characters you can put in a string variable in a programming language can be represented in XML documents. If not careful, this situation can lead to unexpected runtime errors.

 

In addition, we recommend using the PERL API since it will always decode the text for you.

as a recommendation is actually that you can program a function that decode the soap call response.

Any text that contains a character other than the below (where C is a character in java) will be encoded to base 64

c > 31 || c == '\t' || c == '\n' || c == '\r'

Pedro A. Batista
Customer Support Engineer

If you find that this or any other post resolves your issue, please be sure to mark it as an accepted solution.
If you are satisfied with anyone’s response please remember to give them a KUDOS by clicking on the THUMB at the bottom left of the post and show your appreciation.
Tags (2)
Regular Contributor.. Curtis Owings Regular Contributor..
Regular Contributor..

Re: Some configs stored as Base64 on HPNA 10.21.05

Jump to solution

Honestly, I can't think of any reason why I would have control characters in a Cisco config file.  Is there an easy way to check for control characters in a config file?

0 Likes
Micro Focus Expert
Micro Focus Expert

Re: Some configs stored as Base64 on HPNA 10.21.05

Jump to solution

the ASCII codes from 0 to 31 are usually encoded.

you can use a soap call to wrap aroung that and translate the base64:

org.apache.commons.codec.binary.Base64.decodeBase64 and ald Java/Groovy coder decodes the output.

 

Pedro A. Batista
Customer Support Engineer

If you find that this or any other post resolves your issue, please be sure to mark it as an accepted solution.
If you are satisfied with anyone’s response please remember to give them a KUDOS by clicking on the THUMB at the bottom left of the post and show your appreciation.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.