If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

Special characters in Report Name kills connection

Started by bpetty, 30 Sep 2010 03:51:51 PM

Previous topic - Next topic

bpetty

I am using the cognos sdk and have noticed that if I create a report named "Tom & Jerry", for example, it will bomb.
If I convert it to "Tom & Jerry" I can insert the report.... and everything appears fine.
If I try to delete or rename that report with or without encoding it... it will fail.
Not only does it fail, but it also kills my connection.

Any advice?

Note:  It appears like the ReportService can handle the escaped value... the ContentManagerService appears to be the one that blows up.  Do I need to escape it differently for that service?

Oh, I get this wonderful error message to: "faultstring :   The server did something wrong"
Ha!

technomorph

Hi,

In the past I have just used a function to escape any reserved characters. I'm pretty sure this is what's recommended in the SDK guide.

VB6

Public Function XMLEncodeString(strSpec As String) As String
'********************************************************
'*
'*  XMLEncodeString - return a string in which the special XML characters
'*                    have been escaped.
'*
'********************************************************

    strSpec = Replace(strSpec, "&", "&")
    strSpec = Replace(strSpec, "<", "&lt;")
    strSpec = Replace(strSpec, ">", "&gt;")
    strSpec = Replace(strSpec, "'", "&apos;")
    strSpec = Replace(strSpec, """", "&quot;")
    XMLEncodeString = strSpec
   
End Function


Cheers


bpetty

Yeah, I don't think that actually works for CMS XPath-ish queries.
Their documentation says to use URL Encoding, example: & = %26 instead of &amp;

Making this change kept my connection alive, but my query can't find my report.

I've opened a ticket with them... I'll post the answer here in case anyone is interested.

bpetty

Ok... I finally got to the bottom of it.

They gave me some bad info at first.  You only URL Encode if you are using it in their URL API.  So & = %26.  Don't XML Encode then URL Encode.

The problem C++ developers have is that they decode the report name for you automatically because they assume you are writting it in Java or C#.  If you are using C++/COM you are in for a world of hurt.  You have to write a custom encoder that parses the xpath string and re-encodes the report name.  You also have to write another method that uses this new encoding function to encode everything in a CBaseClassC object.  Do not forget to also encode the defaultName for each CBaseClass obj in the CBaseClassC array.  You don't have to worry about any of this if you are using the Java or C# SDK.

Note#2: It is a "feature" to kill the service connection if your query fails.  So... if you accedintally forget to encode & as &amp; and try to query for a specific report you will get an exception that essentially means your connection to CMS for example is now dead.  If you share this connection through out your app make sure you reinitialize it!!!