WSE and problems with the C++ compiler

I was working on an article for one of the MSDN developer centers this week and wrote a little WSE web service in C++. The sample code had the SoapActor attribute attached to the web service, which really shouldn’t be a big deal, but as it turns out, it is.
 
The rather inconspicuous lines
 
[SoapActor( "soap://wse.bracketangles.net/secureecho" )]
public ref class  SecureEchoService : public SoapService
 
produce the following error:
 
d:\christoph\C++\WSEConsoleService\SecureEchoService.h(8) : error C2364: 'System::Uri': illegal type for custom attribute
d:\christoph\C++\WSEConsoleService\SecureEchoService.h(8) : error C3725: 'Microsoft::Web::Services2::Messaging::SoapActorAttribute': cannot resolve attribute overload could be 'Microsoft::Web::Services2::Messaging::SoapActorAttribute::SoapActorAttribute(System::Uri __gc *)'
 
When you look up the error in the framework documentation you’ll quickly find:
 
'type': illegal type for custom attribute
 
Names arguments for custom attributes are limited to compile time constants. For example, integral types (int, char, etc.), System::Type*, and System::Object*.
And what the error documentation states is true, not only for C++ projects, but for other languages like C# as well. However, if you look at the line of code with the SoapActor attribute again, you’ll agree that the parameter passed to the constructor is indeed a compile time constant of type String^ . Furthermore, look at WSE docs and you’ll see that there is a constructor for the SoapActor attribute that accepts a parameter of the type String^ … well yeah, or how would the Soap Actor attribute work properly with C# projects?
 
The source of the problem is the C++ compiler sees the constructor overload with a parameter of type Uri, which has a constructor that takes a String^ , and thus picks the wrong constructer overload – the one that takes a Uri – for the Soap Actor. A Uri parameter cannot be a compile time constant because it’s allocated with gcnew and therefore compilation of my web service fails.
 
Upon further investigation, it turns out that even the C++ compiler in Everett, i.e. .Net 1.1, exhibits the same behavior and there is currently no work-around. The bug will be fixed in an upcoming Whidbey build, but for now, me, and everybody else who wants to develop a WSE Web service with the SoapActor attribute in C++, has to wait for Microsoft to issue a hotfix.
 
 
Published Saturday, November 20, 2004 10:19 PM by ChristophDotNet
Filed under: ,

Comments

# re: WSE and problems with the C++ compiler

Sunday, November 21, 2004 9:13 AM by Jason Haley
I am currently learning C++ and have a question, in what instance would you want to use the following syntax?

[SoapActor( S"soap://wse.bracketangles.net/secureecho" )]
public ref class SecureEchoService : public SoapService

I thought to signal a managed String* you needed the S in front of the text or otherwise it would look at it as an unmanaged string (char*)?

# re: WSE and problems with the C++ compiler

Sunday, November 21, 2004 8:15 PM by Christoph
Jason,

Yes, you are absolutely correct managed C++ for .NET 1.x you should specify the S in front of a string literal.

The code snippet I showed is based on the new Whidbey C++/CLI syntax. Note for example the class declaration in the new syntax reads:

public ref class

where the old syntax would be

public __gc class

If you're just getting started with C++ and .NET and you don't have a real-world project where you need it yet, then I recommend you get started on the new syntax rather than on the old one. C++ is getting quite a bit of an overhaul in the Whidbey release and as a result, the code in the new syntax looks much cleaner.

Take a look at Stanley Lippman's (currently at Microsoft Research) blog (http://blogs.msdn.com/slippman). He's blogging a bit on the upcoming changes.

HTH,
Christoph

# Update: WSE 2.0 SP2 adds work-around for the SoapActorArrtibute / C issue

Thursday, November 25, 2004 2:45 AM by TrackBack

# Update: WSE 2.0 SP2 adds work-around for the SoapActorArrtibute / C issue

Thursday, November 25, 2004 2:46 AM by TrackBack

# Sell ephedrine.

Thursday, July 31, 2008 11:37 PM by Ephedrine.

Getting high with ephedrine. Ephedrine to buy. Dangers of ephedrine. Who sells ephedrine diet pills. Someone who used ephedrine. Ephedrine hcl michigan. Mini ephedrine. Baseball player dies from ephedrine. Danger of ephedrine.

# re: WSE and problems with the C++ compiler

Wednesday, June 10, 2009 8:46 PM by gas powered scooters

Help me to find rock gas powered scooters

www.world66.com/.../gas_powered_scoote

# re: WSE and problems with the C++ compiler

Wednesday, July 29, 2009 8:35 AM by name

I want to say thanks!,

# re: WSE and problems with the C++ compiler

Wednesday, July 29, 2009 7:11 PM by name

Is it so important?,

# re: WSE and problems with the C++ compiler

Thursday, July 30, 2009 5:12 AM by name

Help me to find the,

Leave a Comment

(required) 
(required) 
(optional)
(required)