WSDL and Optional Parameters

W

WHY

Since there's no way to create a c# method with optional, or nullable
parameters.

And since you can't write an overloaded web method.

Is it possible to edit the WSDL in conjunction with a c# method to make the
parameter optional, or have a default value at the client consumer?
 
J

Jeff Relf

Hi WHY,

You tapped out: <<
Since there's no way to create a c# method with optional,
or nullable parameters. >>

No sprintf ( char * Format, ... ) ?

You added: <<
And since you can't write an overloaded web method. >>

Could that be true ? I don't believe it.

You asked: <<
Is it possible to edit the WSDL [ .XML file ]
in conjunction with a c# method
to make the parameter optional,
or have a default value at the client consumer ? >>

Perhaps you could emulates sprintf() by parsing
a string that tells you what parameters are on the stack...

What's a stack ? I hear you asking.

It's a dynamic FILO queue, First In Last Out.

You could create a dynamic FILO queue via a dynamic array,
with pointers to the top and the bottom of the stack.

Of course I would use realloc() to manage a dynamic array...

But I think C#'s automatic allocations
could do something similar... perhaps using the VAR type.
 
W

WHY

Jeff Relf wrote:

But I think C#'s automatic allocations
could do something similar... perhaps using the VAR type.

You rant and spew acuneiform you want so much to be a c# programmer so you
can get a job.

But let me tell you -- there is only one real language: Graffiti 2 and it's
part of the Palm OS. I spend the whole weekend learning the little
cuneiform symbols and it was very cool.

I can sync up Linux with KPilot -- no problem.
 
T

Thomas Edison

But I think C#'s automatic allocations
could do something similar... perhaps using the VAR type.

..NET has a Stack class:

Stack s = new Stack();
s.Push(42);
int i = (int)s.Pop();
 
J

Jeff Relf

Hi Thomas Edison,

You mentioned: << .NET has a Stack class:
Stack s = new Stack(); s.Push(42);
int i = (int)s.Pop(); >>

How would that Stack class be added in C# or C++ ?

In C/C++ I would do something like this:
#include <Something.H> // Something.LIB
 
T

Tom Shelton

Hi Thomas Edison,

You mentioned: << .NET has a Stack class:
Stack s = new Stack(); s.Push(42);
int i = (int)s.Pop(); >>

How would that Stack class be added in C# or C++ ?

In C/C++ I would do something like this:
#include <Something.H> // Something.LIB


Well, the stack class is in the System.Collections namespace - but that
resides in System.dll so, you don't actually have to do anything to add
it. If you want to access it with an unqualified name you have to place
a using statement in the file:

using System.Collections;
....

Stack stack = new Stack();

Other wise you would have to write the code like this:

System.Collections.Stack stack = new System.Collections.Stack();
 
J

Jeff Relf

Hi Tom Shelton,

Re: System.Collections.Stack stack
= new System.Collections.Stack();

Upon compiling that in a .CPP file, I got this error:

'System' : undeclared identifier

Re: using System.Collections;

That give me the following errors:

1. missing ';' before '.'

2. 'System' cannot be used in a using-declaration
 
T

Thomas Edison

Hi Tom Shelton,

Re: System.Collections.Stack stack
= new System.Collections.Stack();

Upon compiling that in a .CPP file, I got this error:

That's C#/.NET code. :)
 
D

Daniel O'Connell [C# MVP]

Jeff Relf said:
Hi Tom Shelton,

Re: System.Collections.Stack stack
= new System.Collections.Stack();

Upon compiling that in a .CPP file, I got this error:

'System' : undeclared identifier

Re: using System.Collections;

That give me the following errors:

1. missing ';' before '.'

2. 'System' cannot be used in a using-declaration

For managed C++ you have to write
using namespace System::Collections;
If memory serves.
 
D

Daniel O'Connell [C# MVP]

Jeff Relf said:
Hi WHY,

You tapped out: <<
Since there's no way to create a c# method with optional,
or nullable parameters. >>

No sprintf ( char * Format, ... ) ?

Different concept. ... is analgous to the params keyword in C#

public void sprintf(string format, params string[] parameters);

would work. However, its not the same as a VB optional parameter or an SQL
style nullable type. C# gains the latter in 2.0.

I do'nt know if params maps to WSDL or not.
You added: <<
And since you can't write an overloaded web method. >>

Could that be true ? I don't believe it.

WSDL works based on names, you cannot create overloads because the message
name determines which method is called. Two methods with teh same name
clash. I don't know the specifics but there is an attribute that will allow
you to change the method name.
Of course I would use realloc() to manage a dynamic array...

But I think C#'s automatic allocations
could do something similar... perhaps using the VAR type.

There *is* no VAR type, please learn the langauge before responding, -_-.
ArrayList, Stack, Queue, etc handle it for you. There is no simple
reallocation operation like C provides as it isn't always really logical to
do so, writing a dynamic array class isn't terribly hard, even if it is a
waste of time.
 
J

Jeff Relf

Hi Thomas Edison,

Re: How System.Collections.Stack
is not available for .CPP files,

Thanks.

That makes sense,
kind of like how C# doesn't support realloc()
and memmove().
 
J

Jessup Silstrom

Jeff said:
Hi Thomas Edison,

Re: How System.Collections.Stack
is not available for .CPP files,

Thanks.

That makes sense,
kind of like how C# doesn't support realloc()
and memmove().

Why would a language with automatic garbage collection need to do this ?
 
J

Jeff Relf

Hi Jessup Silstrom,

Re: C# not supporting realloc() and memmove().

You asked, <<
Why would a language with automatic garbage collection
need to do this ? >>

Even if supporting functions that
have been around for decades
means absolutely nothing to you...

realloc() and memmove() provide much more
control over how memory gets allocated, used
and reclaimed.

But then you've never used those 2 routines, have you.
 
P

PastaVerde

Hi Tom Shelton,

Re: System.Collections.Stack stack
= new System.Collections.Stack();

Upon compiling that in a .CPP file, I got this error:

'System' : undeclared identifier

Re: using System.Collections;

That give me the following errors:

1. missing ';' before '.'

2. 'System' cannot be used in a using-declaration

As Tom mentionned already, that was a snippet of C# code. A "managed
C++" example (without much error checking) might look as follow:

#include <stdio.h>

#using <mscorlib.dll>
using namespace System;

#using "System.dll"
using namespace System::Collections;

public __gc class CVerySimple {
int m_nData;
public:
CVerySimple (int nData) : m_nData(nData) {}
const int get() { return m_nData; }
};

void main (void)
{
Stack* stack = new Stack();
CVerySimple *val = new CVerySimple (1234);

stack->Push(val);
CVerySimple *result = dynamic_cast<CVerySimple*>(stack->Pop());

if (val->get() == result->get()) {
printf ("It works!\n");
} else {
printf ("Error, result = %d\n", result->get());
}
}

Note that you'd need to use the /clr switch on the compiler command
line for the above snippet to compile. This tells the compiler that
the code might contains some .NET stuff and that you want to target
the common language runtime instead of the x86 processor.

Suppose that you saved the above snippet in a file called stack.cpp,
you'd run

cl /clr stack.cpp

to compile it.

If you don't have Visual Studio .NET, get a free version of the
Microsoft Optimizing C/C++ Compiler here:

http://msdn.microsoft.com/visualc/vctoolkit2003/

Just in case you'd like to check a C# example, it would look like
this:

using System;
using System.Collections;

namespace SimpleExample
{
class SimpleContainer {
// member(s)
public int data; // public for simplicity
// constructor
public SimpleContainer (int value)
{
this.data = value;
}
}

class SimpleClass
{
static void Main ()
{
try {

Stack stack = new Stack();
SimpleContainer val = new SimpleContainer(1234);

Console.WriteLine ("First test:");

stack.Push(val);
SimpleContainer result = (SimpleContainer)stack.Pop();

if (val.data == result.data) {
Console.WriteLine (" It works!");
} else {
Console.WriteLine (" Error, result = {0}",
val.data);
}

Console.WriteLine ("Second test:");

stack.Pop(); // stack was empty

} catch (InvalidOperationException e) {
Console.WriteLine (" Exception thrown: {0}",
e.Message);
}
}
}
}

use

csc stack.cs

to compile.

Or course you need the .NET framework to compile and run both samples.

You can get it from here:

http://tinyurl.com/95zt
http://www.microsoft.com/downloads/...e3-f589-4842-8157-034d1e7cf3a3&displaylang=en

If you want to begin playing with C#, be sure to try the Snippet
Compiler:

http://www.sliver.com/dotnet/SnippetCompiler/

The C# language specification is here:

http://tinyurl.com/n9d7
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csspec/html/CSharpSpecStart.asp

Here is the .NET Framework class library reference:

http://tinyurl.com/1qzi
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/cpref_start.asp

Finaly, the .NET Framework SDK (lot's of samples and documentation)

http://tinyurl.com/97x7
http://www.microsoft.com/downloads/...a6-3647-4070-9f41-a333c6b9181d&displaylang=en

....everything to get you started if you want to...

--PV
 
J

Jeff Relf

Hi PastaVerde,

Thanks for showing all that code, very enjoyable...
a fun comparison.

Thanks for this link too:
http://msdn.microsoft.com/visualc/vctoolkit2003/

Although I already had the latest Platform SDK,
I didn't have the Microsoft Optimizing C/C++ Compiler.
( I'm using VC6 on Win XP )

At about 3 minutes per meg,
my spotty dialup service might be able to down load it
in about an hour and a half.

I guess that gives me the
" .NET Framework Common Language runtime ".
( Whatever that means )
but I think I'll pass on the " .NET framework "
and the " .NET framework SDK " ...
( how confusing ) thanks anyways.
 
N

Name:

Jeff Relf said:
Hi PastaVerde,

Thanks for showing all that code, very enjoyable...
a fun comparison.

Thanks for this link too:
http://msdn.microsoft.com/visualc/vctoolkit2003/

Although I already had the latest Platform SDK,
I didn't have the Microsoft Optimizing C/C++ Compiler.
( I'm using VC6 on Win XP )

At about 3 minutes per meg,
my spotty dialup service might be able to down load it
in about an hour and a half.

Jeff, why not just take a blank cdr(w) into one of the Udub's libraries,
download and burn it?

Proof that hanging around *nix folks makes you stupid.
 
J

Jeff Relf

Hi Name:,

Re: Downloading the Microsoft Optimizing C/C++ Compiler,

You wrote: <<
Jeff, why not just take a blank cdr(w)
into one of the Udub's libraries,
download and burn it ?

Proof that hanging around *nix folks makes you stupid.
The download failed, so maybe I will do that.

I probably should've done that with the Platform SDK too,
instead of paying 10 bucks and having it shipped.

But it costs me about 10 bucks
for a pack of blank CDs anyways.
( Rebates are cheaper, but a real hassle )

And waiting around for a 300+ meg download
isn't much fun... even with a fast connection.
 
T

Tom Shelton

Hi Thomas Edison,

Re: How System.Collections.Stack
is not available for .CPP files,

Thanks.

That makes sense,
kind of like how C# doesn't support realloc()
and memmove().

// You can work with unmanaged memory....

using System.Runtime.Interop.Services;

....

IntPtr memPtr = Marshal.AllocHGlobal (numberOfBytesRequired);

....

// Oh, I need to realloc it...
memPtr = Marshal.ReallocHGlobal (memPtr, theNewSize);

....

// Ok, were done...
Marshal.FreeHGlobal (memPtr);

Nothing, exactly equivalent to memmove (at least in the unmanaged sense) -
but, you could implement it your self, or just make a call to the C runtime
to access the call dynamically. But all of this is almost never necessary.
 
T

Tom Shelton

Hi Tom Shelton,

Re: System.Collections.Stack stack
= new System.Collections.Stack();

Upon compiling that in a .CPP file, I got this error:

'System' : undeclared identifier

Re: using System.Collections;

That give me the following errors:

1. missing ';' before '.'

2. 'System' cannot be used in a using-declaration

This is C#. You asked how you would access the Stack class from C# - I
gave an example.
 
P

PastaVerde

Thanks for this link too:
http://msdn.microsoft.com/visualc/vctoolkit2003/

Although I already had the latest Platform SDK,
I didn't have the Microsoft Optimizing C/C++ Compiler.
( I'm using VC6 on Win XP )

I'm not sure if/how you can plug the free 2003 command-line compiler
in VC6, i.e. use it directly from within the 6.0 IDE.

Another option to try managed C++ is to get the beta of Visual C++
Express 2005, currently a free download (but they ask you to
register):

http://lab.msdn.microsoft.com/express/visualc/default.aspx

This comes with a new IDE and a pre-release version of the .NET
Framework 2.0 (you can also target native x86 if you like)

--PV
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top