Webservice sample for VS2005

J

jhcorey

Hello,
I'm trying to figure out how to reference a web service from a
VS2005 web site project. I know how to do this in VS2003.

I've been combing msdn for samples, but I've only found the
MovieCollection app,
which is a windows app, and doesn't compile for me.

If anybody can point me to a sample I'd appreciate it.

TIA,
Jim
 
C

Chris Botha

Right-click on the project itself in the Solution Explorer for the context
menu, or click the Project menu item up top, select Add Web Reference, and
the rest is the same.
 
J

jhcorey

I can do that much, but to me it's not the same after that.

In VS2003 I can then add the webservice namespace, i.e
I type:
using myProject.

At this point the web service I've added pops up in intellisense.
Then I can go ahead and write code using the methods from the web
service.

In VS2005 I can't figure out how to add the namespace or how to get
references to the methods.

Example: Instead of having a project called "myProject", I now have a
web site called "http:localhost/myProject". I've added a web reference
to "mySevice", but I can't figure out how to use these in the code.
 
C

Chris Botha

So after you successfully added the Web reference, and if you used the
default name that VS supplies when adding the Web reference - namely
localhost, you should be able to declare it
Dim MyService as localhost.Service1 = new localhost.Service1
and intellisense should be there, it works for me.

Did you use VS2005 to write the Web service? The reason I am asking is that
you might have created a File System Web Site rather than a Local IIS Web
Site. In this case I don't think you would be able to add a Web reference to
the client project though.
 
J

jhcorey

Chris,
Thanks for your replies.

What I actually have in the project is a folder called
App_WebReferences.
Underneath that is "2ksqldev4" (what I referred to . This is a server
that has MS Reporting Services installed, and it includes a webservice
that I can consume from VS2003.
Following your example, in C#, I should be able to declare a variable
like
2ksqldev4.Service1 myService = new 2ksqldev4.Service1();
but this does not work.
I can try it from VB.
 
C

Chris Botha

What happens if you go "Project" then "Add Web Reference".
The wizard comes up, click "Web services on the local machine".
It will do it's thing and display a list. You say you are adding a Web
reference to Report Server - incidentally this service is called
"ReportServer" as well, find it in the list and click on it.
On the right hand side, maybe give it a better name, change "localhost" to
something like "MSRepSrvr" and click Add Reference.
In your app then use it like
MSRepSrvr.ReportingService theSrvice = new MSRepSrvr.ReportingService();
Intellisense should be there, it should not have anything to do with VB.
 
J

jhcorey

Well, that was interesting. I renamed it, similar to your suggestion,
and it works. Change it back and it doesn't. Evidently having a name
that starts with a number is illegal.
Thanks for working through this.
 

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

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,281
Latest member
Pedroaciny

Latest Threads

Top