You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@axis.apache.org by "nadir amra (JIRA)" <ax...@ws.apache.org> on 2008/10/09 18:04:44 UTC

[jira] Issue Comment Edited: (AXISCPP-882) Use C++ namespaces to prevent symbol collisions

    [ https://issues.apache.org/jira/browse/AXISCPP-882?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12638312#action_12638312 ] 

nadiramra edited comment on AXISCPP-882 at 10/9/08 9:03 AM:
-------------------------------------------------------------

Moving comment from AXISCPP-553 to here.  

Emanuel Norrbin - 28/Mar/06 04:50 AM wrote the followin:

I have two wsdl:s that generate server C++ stubs with classes that have the same C++ names but different interfaces/implementations. Since these web services are compiled into separate .so libraries there is no problem with this at compile time.

For separate reasons we need to load libraries using the RTLD_GLOBAL flag (using g++ on Linux) as mentioned in the original post. Just like Tim we really need this flag when libraries are loaded by the axis_server for our product to work. Now for the gotcha: With this flag set, any of the two classes having the same names can be loaded by axis when serializing/deserializing a soap message. This will ofcourse not work if the wrong class is picked. We have worked around this problem by putting one of the generated classes in a separate namespace with corresponding changes to the implementation. An alternative is to never use the same class name, but this is hard to enforce and wsdl2ws itself produces classes with the same names, e.g. AxisServiceException which is always generated.

I dont know if this could solve the problems found by Adrian (see comment above) but it would be easy to fix in wsdl2ws for C++:

1. Generate a unique namespace for each web service. A GUID would work.
2. Let each Axis generated class belong to this namespace.
3. Put a "using namespace XXX" in the beginning of each *.cpp file (after the #includes section).

Please give your comments to this.

      was (Author: nadiramra):
    Moving comment from AXISCPP-553 to here.  


I found another interesting problem related to this.

I have two wsdl:s that generate server C++ stubs with classes that have the same C++ names but different interfaces/implementations. Since these web services are compiled into separate .so libraries there is no problem with this at compile time.

For separate reasons we need to load libraries using the RTLD_GLOBAL flag (using g++ on Linux) as mentioned in the original post. Just like Tim we really need this flag when libraries are loaded by the axis_server for our product to work. Now for the gotcha: With this flag set, any of the two classes having the same names can be loaded by axis when serializing/deserializing a soap message. This will ofcourse not work if the wrong class is picked. We have worked around this problem by putting one of the generated classes in a separate namespace with corresponding changes to the implementation. An alternative is to never use the same class name, but this is hard to enforce and wsdl2ws itself produces classes with the same names, e.g. AxisServiceException which is always generated.

I dont know if this could solve the problems found by Adrian (see comment above) but it would be easy to fix in wsdl2ws for C++:

1. Generate a unique namespace for each web service. A GUID would work.
2. Let each Axis generated class belong to this namespace.
3. Put a "using namespace XXX" in the beginning of each *.cpp file (after the #includes section).

Please give your comments to this.
  
> Use C++ namespaces to prevent symbol collisions
> -----------------------------------------------
>
>                 Key: AXISCPP-882
>                 URL: https://issues.apache.org/jira/browse/AXISCPP-882
>             Project: Axis-C++
>          Issue Type: New Feature
>          Components: Basic Architecture
>    Affects Versions: 1.5 Final
>            Reporter: Chip Stettler
>
> Identically named data structures are being returned in many of our WSDLs and causing symbol resolution and name conflicts.   We are currently hand editing generated code to add C++ namespace declarations.  I have noticed commercial products doing the same.   We are currently addressing this via scripts.  Would be a nice feature for the generator.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-c-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-c-dev-help@ws.apache.org