473,624 Members | 2,117 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Big-Picture Question (Web Services, RegNow)

I was wondering if some of you could advise me on the following issue.

I ported my code that generates shareware licenses to a C# class. I'd like
to get to the point where this is done online (and eventually done
automatically).

What is the best way to expose this functionality on the Web? Are Web
services the answer--I know almost nothing about them?

I'm also wanting to work with RegNow. While they don't seem to currently
support registration via Web services, they might if pushed.

Am I on track here? Does this seem like a reasonable approach? Can anyone
point me to where I could find more information on these issues?

Thanks!

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
Nov 17 '06 #1
23 1636
"Jonathan Wood" <jw***@softcirc uits.comwrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..

Webservices are the solution when you are faced with the following two
situations:

1) your code needs to be available over the web (duh!)

2) your code needs to be available in more than one web app

Are you intending to provide some sort of web portal which other
organisations can use to provide on-line licence keys for their apps, or
maybe for online software activation the way Microsoft (and now others)
do...?
Can anyone point me to where I could find more information on these
issues?
There are literally hundreds of examples on the net - just Google...

Writing a webservice really is very simple these days with Visual
Studio.NET - it pretty much isolates the developer from all the SOAP stuff
(though it's still there, of course) - you pretty much just point and click
to add a webservice to an existing site, fill in the code, compile, test and
deploy.
Nov 18 '06 #2
Hi Mark,

Mark Rae wrote:
"Jonathan Wood" <jw***@softcirc uits.comwrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..

Webservices are the solution when you are faced with the following two
situations:

1) your code needs to be available over the web (duh!)

2) your code needs to be available in more than one web app
I see at least one more reason to use web services:

3) You want to transmit (relatively) complex objects without having to
deal with the serialization/deserialization mechanisms.

To me, it's the main reason why I would use SOAP web services over a
simple ASHX custom handler, for example. It's neat to add a web
reference to your application and to have the whole proxy created
automatically for you...

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Nov 18 '06 #3
Thanks for the input. I'm contacting RegNow to see why this is not an
option.

BTW, does anyone know of a way to return multiple fields from a Web service?
I'm only able to see how to return a single field (the function's return
value).

Thanks.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
"Mark Rae" <ma**@markNOSPA Mrae.comwrote in message
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
"Jonathan Wood" <jw***@softcirc uits.comwrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..

Webservices are the solution when you are faced with the following two
situations:

1) your code needs to be available over the web (duh!)

2) your code needs to be available in more than one web app

Are you intending to provide some sort of web portal which other
organisations can use to provide on-line licence keys for their apps, or
maybe for online software activation the way Microsoft (and now others)
do...?
>Can anyone point me to where I could find more information on these
issues?

There are literally hundreds of examples on the net - just Google...

Writing a webservice really is very simple these days with Visual
Studio.NET - it pretty much isolates the developer from all the SOAP stuff
(though it's still there, of course) - you pretty much just point and
click to add a webservice to an existing site, fill in the code, compile,
test and deploy.

Nov 18 '06 #4
Hi,

Jonathan Wood wrote:
Thanks for the input. I'm contacting RegNow to see why this is not an
option.

BTW, does anyone know of a way to return multiple fields from a Web service?
I'm only able to see how to return a single field (the function's return
value).

Thanks.
The constraints for web methods are exactly the same as for "normal"
methods: One return value only, but it can be anything including array
(if you have many "fields" of the same type), or an object including
different properties.

All public properties/attributes of the returned object will be
serialized and transmitted.

However, if you can, I recommend to keep it simple. First you'll avoid
serialization problems, and second, remember that web services clients
are not only C#, but could be anything, including JavaScript (it's quite
easy to make a web service call using JavaScript). For example, instead
of transmitting a DateTime object, why not transmit a string
representation of that DateTime... you get the idea.

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Nov 18 '06 #5
Laurent,
The constraints for web methods are exactly the same as for "normal"
methods: One return value only, but it can be anything including array (if
you have many "fields" of the same type), or an object including different
properties.
That's interesting. I tried using out parameters but the VS 2005 testing
mechanism for asmx files does not support that. I just tried returning a
string array. This is supported. Unfortunately, there is no way to name each
of the string fields returned.
However, if you can, I recommend to keep it simple. First you'll avoid
serialization problems, and second, remember that web services clients are
not only C#, but could be anything, including JavaScript (it's quite easy
to make a web service call using JavaScript). For example, instead of
transmitting a DateTime object, why not transmit a string representation
of that DateTime... you get the idea.
Yes, and I agree wholeheartedly. However, I'm writing a service that
provides a registration code for my software. It seems like it would be more
straightforward (and more standard?) to include two return values: One that
indicate success or failure, and another that provides the registration code
(or error message on failure).

I don't want to do anything that is out of the ordinary but it seems like
this would be a good, simple approach, one for which XML is well suited. If
this is not at all standard, I could include a pass/fail string at the start
of my return string. But only seems like it would be harder for the consumer
of my Web service to deal with.

Thanks!

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
Nov 18 '06 #6
Hi,

Jonathan Wood wrote:
Laurent,
>The constraints for web methods are exactly the same as for "normal"
methods: One return value only, but it can be anything including array (if
you have many "fields" of the same type), or an object including different
properties.

That's interesting. I tried using out parameters but the VS 2005 testing
mechanism for asmx files does not support that. I just tried returning a
string array. This is supported. Unfortunately, there is no way to name each
of the string fields returned.
An array's fields are not named. Once again, it's the same as for a
normal method.
>However, if you can, I recommend to keep it simple. First you'll avoid
serializatio n problems, and second, remember that web services clients are
not only C#, but could be anything, including JavaScript (it's quite easy
to make a web service call using JavaScript). For example, instead of
transmitting a DateTime object, why not transmit a string representation
of that DateTime... you get the idea.

Yes, and I agree wholeheartedly. However, I'm writing a service that
provides a registration code for my software. It seems like it would be more
straightforward (and more standard?) to include two return values: One that
indicate success or failure, and another that provides the registration code
(or error message on failure).
That's easy to do. Create a class:

public class ReturnValue
{
public bool success = false;
public string registrationCod e = "";
}

then, in your web method, declare:

[WebMethod]
public ReturnValue GetRegistration Code()
{
ReturnValue returnValue = new ReturnValue();
returnValue.suc cess = true;
returnValue.reg istrationCode = "1234";
return returnValue;
}

As easy as that.
I don't want to do anything that is out of the ordinary but it seems like
this would be a good, simple approach, one for which XML is well suited. If
this is not at all standard, I could include a pass/fail string at the start
of my return string. But only seems like it would be harder for the consumer
of my Web service to deal with.

Thanks!
HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Nov 18 '06 #7
Laurent,
That's easy to do. Create a class:

public class ReturnValue
{
public bool success = false;
public string registrationCod e = "";
}

then, in your web method, declare:

[WebMethod]
public ReturnValue GetRegistration Code()
{
ReturnValue returnValue = new ReturnValue();
returnValue.suc cess = true;
returnValue.reg istrationCode = "1234";
return returnValue;
}

As easy as that.

Cool! That gives me all the control I need. The book I'm reading said it was
better to stick with basic types but I didn't realize that a class that
contained only public basic types would work as well! That gives me complete
flexibility on the results!

For giggles, I also tried accepting a class as the argument (since I have
quite a few input args). That would be cool also. Unfortunately, the VS Web
service test mechanism did not support this, which makes me think others
might not support it either, so I'll avoid that.

BTW, can you tell me the effect of initializing class variables as you did?
That would seem to bypass the constructor somewhat. I didn't realize you
could do that.

Thanks!

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
Nov 18 '06 #8
Hi,

Jonathan Wood wrote:
Laurent,

Cool! That gives me all the control I need. The book I'm reading said it was
better to stick with basic types but I didn't realize that a class that
contained only public basic types would work as well! That gives me complete
flexibility on the results!

For giggles, I also tried accepting a class as the argument (since I have
quite a few input args). That would be cool also. Unfortunately, the VS Web
service test mechanism did not support this, which makes me think others
might not support it either, so I'll avoid that.
Show the code. Accepting custom types as parameters should also be
supported.

However, note that there are all kind of clients able to send a request
to a web service. The given client is responsible for serializing (i.e.
transforming into XML) the given parameters, and for deserialiazing
(i.e. transforming from XML) the returned value.

If your client is a .NET application, you don't have to worry too much
about it, because the serialization/deserialization mechanism is
automatically provided (by the web reference, also called web service
proxy).

BTW, can you tell me the effect of initializing class variables as you did?
That would seem to bypass the constructor somewhat. I didn't realize you
could do that.
What I did, for simplification, was provide public attributes in the
class. It is not recommended in normal cases, because anyone could
modify the attributes at any time. However, for simple "packing" when
using a web service, that might be sufficient.

When an attribute is public, you can set and get its value without using
properties. Normally, the usual way is rather to create private
attributes, and to provide public get and set accessors, named
properties. In that case, you can choose to initialize the variables
using the constructor.

The following 2 examples are stictly equivalent as for the result of the
operation.

Example 1:

public class Test1
{
public int attrib1 = 0;
}

Test1 test1 = new Test1();
test1.attrib1 = 5;

Example 2:

public class Test2
{
private int attrib2 = 0;
public int Attrib2
{
get { return attrib2; }
set { attrib2 = value; }
}
}

Test2 test2 = new Test2();
test2.Attrib2 = 5;

Example 3:

public class Test3
{
private int attrib3 = 0;
public int Attrib3
{
get { return attrib3; }
set { attrib3 = value; }
}

public Test3( int param3 )
{
attrib3 = param3;
}
}

The differences are:

In the case 2 and 3, you can introduce additional checks in the "set"
property. For example, you may throw an exception if the value is
smaller than 0.

In the case 3, you make sure that the attributes are always initialized.
There is no default constructor. (The examples 1 and 2 also don't have
an explicit default constructor, but the compiler provides one when no
constructor is defined.)

Note that this has nothing to do with web services, it's basic C#. Don't
hesitate to ask more if something is not clear.

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Nov 19 '06 #9
Laurent,
Show the code. Accepting custom types as parameters should also be
supported.

However, note that there are all kind of clients able to send a request to
a web service. The given client is responsible for serializing (i.e.
transforming into XML) the given parameters, and for deserialiazing (i.e.
transforming from XML) the returned value.

If your client is a .NET application, you don't have to worry too much
about it, because the serialization/deserialization mechanism is
automatically provided (by the web reference, also called web service
proxy).
My code is like what is shown below but while it may be supported by some
clients, Visual Studio won't run it for me. If I change the arguments to be
the members of RegArgs, then VS has no trouble with it. Note that while I
may want to access this service from a .NET application, I certainly want it
available to clients using different platforms as well.

[WebService(Name space = "https://www.mydomain.co m/")]
[WebServiceBindi ng(ConformsTo = WsiProfiles.Bas icProfile1_1)]
public class ProductRegistra tion : System.Web.Serv ices.WebService
{
public class RegArgs
{
public string name = "";
public string password = "";
public int productId = 0;
public int cpus = 1;
public string custName = "";
public string custCompany = "";
public string custAddress1 = "";
public string custAddress2 = "";
public string custCountry = "";
public string custPhone = "";
public string custEmail = "";
}

[WebMethod(Descr iption = "Returns registration information for a
product.")]
public string RegisterProduct (RegArgs args)
{
return "BlahBlahBl ah";
}
}
In the case 3, you make sure that the attributes are always initialized.
There is no default constructor. (The examples 1 and 2 also don't have an
explicit default constructor, but the compiler provides one when no
constructor is defined.)
I understood the part about making variables private and exposing them
through properties, and also why that might be beneficial.

I just wasn't used to initializing member variables in place rather than in
the constructor. As you probably know, you cannot initialize a member
variable like that in a C++ class. I wasn't aware you could do it that way
in a C# class. I'm assuming the effect of this is the same as initializing
the variable in a constructor: i.e. the variable is initialized to the
specified value when an instance is created.

Thanks!

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
Nov 19 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
10785
by: jova | last post by:
Does anyone know of a good site where I can learn of this?
8
27453
by: Perception | last post by:
Hello all, If I have a C-like data structure such that struct Data { int a; //16-bit value char; //3 ASCII characters int b; //32-bit value int c; //24-bit value }
3
1837
by: ranjeet.gupta | last post by:
Dear All !! I am not sure the question which I am asking is correct or wrong, but I have heard that storing the data into the big endian helps in gting the more transfer rate, Means we can achive good speed by soring the data in the BIG ENDIAN while transferring, If this is correct, then how it is possible and what is the reason behind this. Any pointers on above will be helpful, (if My question sounds correct)
2
4185
by: James Wong | last post by:
Dear all, I'm using StreamReader to read a text file containing BIG-5 data and found that no matter which encoding method in StreamReader's construction parameter, the BIG-5 contents become garbage under ReadLine method. Does anybody have any idea on this issue? Thanks for your attention and kindly help! Regards,
14
2850
by: ThazKool | last post by:
I want to see if this code works the way it should on a Big-Endian system. Also if anyone has any ideas on how determine this at compile-time so that I use the right decoding or encoding functions, I would greatly appreciate the help. Thanks, Ché #include <iostream>
2
6543
by: bhatia | last post by:
Hello all, If I have a C-like data structure such that struct Data { int a; //16-bit value char; //3 ASCII characters int b; //32-bit value int c; //24-bit value }
5
3140
by: manishster | last post by:
I keep getting the following in my output file , regardless of whether I convert endian-ness or not . How do i get "01 02 03 04" .... Mahamannu output : 04 03 02 01 b0 00 00
17
1655
by: cass27 | last post by:
I am just doing a course on Javascript and have begun to try out different ideas. The effect I wanted was fro the user to click on a graphic. Aprompt box would apprear asking their name and that imfo would be transferred to the top of that page. However the users name will only appear on a seperate page. The code i am using (in brief) is as follows: function getname() {
13
27264
by: junky_fellow | last post by:
Hi guys, I need to convert a big endian integer to little endian integer. (the integer is 4 bytes in size on my implementation). I came up with the following code. I need your comments on this. Please suggest any improvements that can be done. #include <stdio.h> int main(void) {
4
2479
by: Pascal Sartoretti | last post by:
Hello, I want to process big files (e.g. 100 MB) with XQuery. Are there XQuery processors that work in a "SAX-like" way (and not DOM-like), i.e. which don't assume that they have everything in memory ? Thanks for any help Pascal
0
8680
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8624
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8336
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7164
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4082
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2607
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1786
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1485
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.