WinForms and WebServices

  • Thread starter Johnny Jörgensen
  • Start date
J

Johnny Jörgensen

I'm creating a windows forms application that gets data from a databaase on
the net through a webservice.

Of course, it's no problem creating a reference to an already existing web
service in VS.

The problem is that I want the user to be able to install the database and
webservice on his own server and use the winforms application to access it.

That means that at development time I don't know the address for the
webservice and thus I cannot create a reference.

How do I either:

1) Program the winforms program for a webservice that is not yet accessible

AND/OR

2) Change the reference at runtime to a user entered webaddress

????

TIA,
Johnny J.
 
M

Mr. Arnold

Johnny Jörgensen said:
I'm creating a windows forms application that gets data from a databaase
on the net through a webservice.

Of course, it's no problem creating a reference to an already existing web
service in VS.

The problem is that I want the user to be able to install the database and
webservice on his own server and use the winforms application to access
it.

That means that at development time I don't know the address for the
webservice and thus I cannot create a reference.

How do I either:

1) Program the winforms program for a webservice that is not yet
accessible

AND/OR

2) Change the reference at runtime to a user entered webaddress

Why do you need a Web service to do this? Why can't the Windows form
application just access the SQL Server directly?


__________ Information from ESET NOD32 Antivirus, version of virus signature database 4063 (20090508) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com
 
C

Cor Ligthert[MVP]

Johnny,

In addition to the other replies, be aware that the user needs for a
webservice IIS on his own computer, which means a professional version or a
server version.

Cor
 
C

Cor Ligthert[MVP]

Johnny,

In addition to the other replies, be aware that the user needs for a
webservice IIS on his own computer, which means a professional version or a
server version.

Cor
 
J

Johnny J.

OK: Seems like I did a poor job of explaining my problem:

The thought is that the user should be able to install the database and
winservice on his SERVER (which might be his own or a web hotel server). The
user will know how to do this - no need to worry about that.

BUT the winforms application which might be used by other users than the
application owner is not installed on the server but on one or more local
machines.

As to your questions about WHY I want to do this: I'm afraid I cannot tell
you that at this point, and a discussion about the puporse is not in the
least helpful to me.

It would be a great help though, if you could help me solve the problem of
HOW to accomplish it.

Best regards,
Johnny J.
 
J

Johnny J.

OK: Seems like I did a poor job of explaining my problem:

The thought is that the user should be able to install the database and
winservice on his SERVER (which might be his own or a web hotel server). The
user will know how to do this - no need to worry about that.

BUT the winforms application which might be used by other users than the
application owner is not installed on the server but on one or more local
machines.

As to your questions about WHY I want to do this: I'm afraid I cannot tell
you that at this point, and a discussion about the puporse is not in the
least helpful to me.

It would be a great help though, if you could help me solve the problem of
HOW to accomplish it.

Best regards,
Johnny J.
 
J

Johnny J.

OK: Seems like I did a poor job of explaining my problem:

The thought is that the user should be able to install the database and
winservice on his SERVER (which might be his own or a web hotel server). The
user will know how to do this - no need to worry about that.

BUT the winforms application which might be used by other users than the
application owner is not installed on the server but on one or more local
machines.

As to your questions about WHY I want to do this: I'm afraid I cannot tell
you that at this point, and a discussion about the puporse is not in the
least helpful to me.

It would be a great help though, if you could help me solve the problem of
HOW to accomplish it.

Best regards,
Johnny J.
 
J

Johnny J.

OK: Seems like I did a poor job of explaining my problem:

The thought is that the user should be able to install the database and
winservice on his SERVER (which might be his own or a web hotel server). The
user will know how to do this - no need to worry about that.

BUT the winforms application which might be used by other users than the
application owner is not installed on the server but on one or more local
machines.

As to your questions about WHY I want to do this: I'm afraid I cannot tell
you that at this point, and a discussion about the puporse is not in the
least helpful to me.

It would be a great help though, if you could help me solve the problem of
HOW to accomplish it.

Best regards,
Johnny J.
 
J

Johnny J.

OK: Seems like I did a poor job of explaining my problem:

The thought is that the user should be able to install the database and
winservice on his SERVER (which might be his own or a web hotel server). The
user will know how to do this - no need to worry about that.

BUT the winforms application which might be used by other users than the
application owner is not installed on the server but on one or more local
machines.

As to your questions about WHY I want to do this: I'm afraid I cannot tell
you that at this point, and a discussion about the puporse is not in the
least helpful to me.

It would be a great help though, if you could help me solve the problem of
HOW to accomplish it.

Best regards,
Johnny J.
 
J

Johnny J.

OK: Seems like I did a poor job of explaining my problem:

The thought is that the user should be able to install the database and
winservice on his SERVER (which might be his own or a web hotel server). The
user will know how to do this - no need to worry about that.

BUT the winforms application which might be used by other users than the
application owner is not installed on the server but on one or more local
machines.

As to your questions about WHY I want to do this: I'm afraid I cannot tell
you that at this point, and a discussion about the puporse is not in the
least helpful to me.

It would be a great help though, if you could help me solve the problem of
HOW to accomplish it.

Best regards,
Johnny J.
 
C

Cor Ligthert[MVP]

As to your questions about WHY I want to do this: I'm afraid I cannot tell
you that at this point, and a discussion about the puporse is not in the
least helpful to me.
That makes help difficult, that is the same as somebody who comes to a
doctor and tells: I need to use cocaine, but I want to keep my health all
the time.

But the main standard answer is, set your variables in the app.config.sys
(Just open the code for the web service, the url is there somewhere)

The web service it self should be installed as every other asp.net
application.

Cor
 
C

Cor Ligthert[MVP]

As to your questions about WHY I want to do this: I'm afraid I cannot tell
you that at this point, and a discussion about the puporse is not in the
least helpful to me.
That makes help difficult, that is the same as somebody who comes to a
doctor and tells: I need to use cocaine, but I want to keep my health all
the time.

But the main standard answer is, set your variables in the app.config.sys
(Just open the code for the web service, the url is there somewhere)

The web service it self should be installed as every other asp.net
application.

Cor
 
J

Johnny J.

Sorry Cor, I appreciate you taking the time to review my question and
answers but you're focusing on the wrong thing and completely missing the
point.

The WHY is not the problem it is the HOW, and I explained that in my
original post. For some reason people are missing the point. I'll try to
elaborate again:

Let us say like this: I have programmed the webservice. It's done and ready
to be installed. I don't know where it will be installed and I don't have
the URL (even if I had it would be no help as the service is not installed
there yet).

Now I need to program the accompanying Winforms app. To be able to use the
methods and properties of the service I HAVE TO add a web reference to the
service in the application references and the VS guide that helps you doing
that has to be able to access the service itself to list it's methods and
properties.

This is not possible because the service is not installed live anywhere. So
I cannot add the web reference and thus I cannot create a web service object
instance and use the web service methods and properties in the app.

That is my problem. I'm sure there's a good solution to it but if I knew
what that was, I wouldn't be asking the question.

Some thoughts that occurred to me while I wrote this answer:

1) I don't know if I could write the code anyway - I'm sure if I tried to
instanciate a web service object and use it's methods without having the web
reference, I wouldn't be able to compile the app? And I wouldn't have any
intellisense help. This method would also require that I could set the
reference later at runtime so that the winapp could actually find the real
(and by that time installed) service.

2) I don't know if I could simply reference my VS web service project
instead. This method would also require that I could set the reference later
at runtime so that the winapp could actually find the real (and by that time
installed) service.

3) I suppose I could install a "dummy" service on my own web server and
reference that. This method would also require that I could set the
reference later at runtime so that the winapp could actually find the real
(and by that time installed) service.

None of this seems like a real solution to me, so I was hoping somebody else
had had to do this before and was able to help me.

As I see it, my problem is sort of like loading a dll at runtime - only with
a web service instead.

Best regards
Johnny J.
 
J

Johnny J.

Sorry Cor, I appreciate you taking the time to review my question and
answers but you're focusing on the wrong thing and completely missing the
point.

The WHY is not the problem it is the HOW, and I explained that in my
original post. For some reason people are missing the point. I'll try to
elaborate again:

Let us say like this: I have programmed the webservice. It's done and ready
to be installed. I don't know where it will be installed and I don't have
the URL (even if I had it would be no help as the service is not installed
there yet).

Now I need to program the accompanying Winforms app. To be able to use the
methods and properties of the service I HAVE TO add a web reference to the
service in the application references and the VS guide that helps you doing
that has to be able to access the service itself to list it's methods and
properties.

This is not possible because the service is not installed live anywhere. So
I cannot add the web reference and thus I cannot create a web service object
instance and use the web service methods and properties in the app.

That is my problem. I'm sure there's a good solution to it but if I knew
what that was, I wouldn't be asking the question.

Some thoughts that occurred to me while I wrote this answer:

1) I don't know if I could write the code anyway - I'm sure if I tried to
instanciate a web service object and use it's methods without having the web
reference, I wouldn't be able to compile the app? And I wouldn't have any
intellisense help. This method would also require that I could set the
reference later at runtime so that the winapp could actually find the real
(and by that time installed) service.

2) I don't know if I could simply reference my VS web service project
instead. This method would also require that I could set the reference later
at runtime so that the winapp could actually find the real (and by that time
installed) service.

3) I suppose I could install a "dummy" service on my own web server and
reference that. This method would also require that I could set the
reference later at runtime so that the winapp could actually find the real
(and by that time installed) service.

None of this seems like a real solution to me, so I was hoping somebody else
had had to do this before and was able to help me.

As I see it, my problem is sort of like loading a dll at runtime - only with
a web service instead.

Best regards
Johnny J.
 
C

Cor Ligthert[MVP]

That was what I understood,

But you need to make yourself a program (you can set it in you windows
program but then you need probably roles as you have more users), which
change the configfile with the correct Url and Connection String.

That can be used as the web service are installed.
Like you told that you cannot controlled that, then you should not try to do
that.

As the web service (the same is with a normal service by the way) not needed
in your situation, then try to avoid it, therefore the advice from the
others this is not simply loading a dll, the web service is normally open
for the whole world as it is not done well.

This problem is for everybody the same, you can make a lot to make it
easier, but in the real world you cannot go around security (settings),
which is controlled by a system administrator.

Cor
 
C

Cor Ligthert[MVP]

That was what I understood,

But you need to make yourself a program (you can set it in you windows
program but then you need probably roles as you have more users), which
change the configfile with the correct Url and Connection String.

That can be used as the web service are installed.
Like you told that you cannot controlled that, then you should not try to do
that.

As the web service (the same is with a normal service by the way) not needed
in your situation, then try to avoid it, therefore the advice from the
others this is not simply loading a dll, the web service is normally open
for the whole world as it is not done well.

This problem is for everybody the same, you can make a lot to make it
easier, but in the real world you cannot go around security (settings),
which is controlled by a system administrator.

Cor
 
J

Johnny J.

Thank you, Cor - but you still don't answer my question I'm afraid. You're
still focusing on the wrong issues.

I'm aware of the security problems that can arise with this kind of an
arrangement, but I can assure you that a web service IS needed for the
purpose. How else do you imagine having programs on multiple computers all
over the world - not connected to the same network - access the same
database? This is however the discussion I do not wish to get into because
it's wasting my time and not solving my problems.

My problems is not at all as abstract as that - it's quite straightforward.
If I write in app my code:

Dim myWebservice as new MyWebServiceReference
myWebservice.InvokeMyMethod(byval PassThisParameter as Integer)

then it won't compile - because I don't have a reference to the web service
in my project - thus VS doesn't know what MyWebServiceReference is and that
a method called InvokeMyMethod (just an example) even exists.

So you say that I can change the web service URL in the config file at run
time... OK, That's one thing. That's an answer I can actually use, but it's
not answer enough...

I might even be able to ADD the service name in the config file at runtime?
(Because don't forget: at design time I don't have any reference to add to
the project)

But that doesn't answer my question of how I write the code and compile the
app when the compiler has no reference to "consult".

/Johnny J.
 
J

Johnny J.

Thank you, Cor - but you still don't answer my question I'm afraid. You're
still focusing on the wrong issues.

I'm aware of the security problems that can arise with this kind of an
arrangement, but I can assure you that a web service IS needed for the
purpose. How else do you imagine having programs on multiple computers all
over the world - not connected to the same network - access the same
database? This is however the discussion I do not wish to get into because
it's wasting my time and not solving my problems.

My problems is not at all as abstract as that - it's quite straightforward.
If I write in app my code:

Dim myWebservice as new MyWebServiceReference
myWebservice.InvokeMyMethod(byval PassThisParameter as Integer)

then it won't compile - because I don't have a reference to the web service
in my project - thus VS doesn't know what MyWebServiceReference is and that
a method called InvokeMyMethod (just an example) even exists.

So you say that I can change the web service URL in the config file at run
time... OK, That's one thing. That's an answer I can actually use, but it's
not answer enough...

I might even be able to ADD the service name in the config file at runtime?
(Because don't forget: at design time I don't have any reference to add to
the project)

But that doesn't answer my question of how I write the code and compile the
app when the compiler has no reference to "consult".

/Johnny J.
 
M

Mr. Arnold

Johnny J. said:
OK: Seems like I did a poor job of explaining my problem:

The thought is that the user should be able to install the database and
winservice on his SERVER (which might be his own or a web hotel server).
The user will know how to do this - no need to worry about that.

BUT the winforms application which might be used by other users than the
application owner is not installed on the server but on one or more local
machines.

As to your questions about WHY I want to do this: I'm afraid I cannot tell
you that at this point, and a discussion about the puporse is not in the
least helpful to me.

It would be a great help though, if you could help me solve the problem of
HOW to accomplish it.

I think somewhere in the information it is going to show how to discover a
local ASP.Net Web service from a Win form application.

http://msdn.microsoft.com/en-us/library/aa984086(VS.71).aspx


__________ Information from ESET NOD32 Antivirus, version of virus signature database 4063 (20090508) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com
 
M

Mr. Arnold

Johnny J. said:
OK: Seems like I did a poor job of explaining my problem:

The thought is that the user should be able to install the database and
winservice on his SERVER (which might be his own or a web hotel server).
The user will know how to do this - no need to worry about that.

BUT the winforms application which might be used by other users than the
application owner is not installed on the server but on one or more local
machines.

As to your questions about WHY I want to do this: I'm afraid I cannot tell
you that at this point, and a discussion about the puporse is not in the
least helpful to me.

It would be a great help though, if you could help me solve the problem of
HOW to accomplish it.

I think somewhere in the information it is going to show how to discover a
local ASP.Net Web service from a Win form application.

http://msdn.microsoft.com/en-us/library/aa984086(VS.71).aspx


__________ Information from ESET NOD32 Antivirus, version of virus signature database 4063 (20090508) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com
 

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