Consuming a Web Service - what am I doing wrong?

Using VS 2008 with Visual Basic I am trying to develop a web service to provide data from my web site's database to a Windows program.

1.    Using the templates I created a web service in a new project within the solution for my GDBChart Windows program.  At this stage the web service contains a class, service.vb, with the default "Hello World" function only.    This tests OK:  select service.asmx and press F5 displays the "Service Web Service web page showing HelloWorld,  clicking HelloWorld shows an [Invoke] button and the SOAP 1.1, SOAP 1.2, and HTML POST formats, and finally clicking [Invoke] returns XML <string>Hello World</string>.   Everything is OK so far.

2.    I added a service reference to the GDBChart project, naming it GDBWebService.  Solution Explorer now shows: -
               My Project
               Service References
               ...   (various other stuff, not relevant)

3.     Within Form1 I added an event handler to use the web service. Within this I wrote
             Dim GDBW as New GDBWebService.  ...
        and VS2008 found GDBWebService and gave options of

Shouldn't I have a "HelloWorld" method?   The examples of Web Services all seem to have the equivalent of "HelloWorldString = GDBW.HelloWorld".  I tried using HelloWorldRequest and ServiceSoapClient, but neither produced the results I wanted, and usually failed with a VB runtime error.  

I'm sure that there is something simple that I've misunderstood and am getting wrong, and once this is sorted I'll be away and can get on to real web services that access the database in useful ways. What have I screwed up?

Thank you, Robert Barnes



1/4/2009 9:36:02 PM 7071 articles. 0 followers. Follow

16 Replies

Similar Articles

[PageSpeed] 33

you should be able to type gdbwebservice without the new or dim and get some intellisence.


Good Luck

1/4/2009 10:55:47 PM

You need to get an instance of the web service class before you can call the HelloWorld method.  My VB syntax is more than a little rusty, but something like:

Dim GDBW as New GDBWebService()


1/4/2009 11:09:43 PM

 This is exactly what I had expected to write, based on the book I am trying to follow.   However when I write
    Dim GDBW As New GDBWebService()
I get an error message "Type Expected". 

If I write
    Dim GDBW As New GDBWebService.ServiceSoapClient
then this compiles without a message, as does the following statement
    Dim HelloWorldString as String = GDBQ.HelloWorld

but it fails on execution, with message "InvalidOperationException was unhandled" with details "An endpoint configuration section for contract 'GDBWebService.ServiceSoap' could not be loaded because more than one endpoint configuration for that contract was found. Please indicate the preferred endpoint configuration section by name. "

I suspect that I should be able to write code like yours, but I'm missing something that defines GDBWebService the right way. Perhaps an Imports statement?


1/5/2009 12:56:26 AM

 Intellisense for GDBWebService, without Dim or New, is the same as before except that the entry "ServiceSoapClient" doesn't appear, but "ServiceSoap" and "ServiceSoapChannel" do.   Either way, I think I need to create an instance of this class with   Dim xxx As New GDBWebService.   My book says "Call the XML Web Service through the proxy.  ... You instantiate it as you would any other class" and the book's example is  "QuoteServiceSoapClient quoteservice = new QuoteServiceSoapClient()"

1/5/2009 1:15:08 AM

How did you create the web service?  If you just create an empty asmx file, it should work as with my previous code.

The code fragment I posted should work for a vanilla asmx file (the "Web Service" template in Visual Studio) -- but such a file shouldn't include the other methods that you've mentioned.

1/5/2009 2:22:06 AM

The web service was created from the VS2008 template, with no changes.  When I created the service reference, I clicked the [advanced] button and checked "Generate Asynchronous Methods", as I am going to need these later.  I believe that these are why there are the extra methods: according to my book if this is checked then they are generated AS WELL AS the synchronous methods, and by choosing whether to use "HelloWorld" or "BeginHelloWorld" you choose whether to implement a synchronous or asynchrounous call.  My problem is that I see neither "HelloWorld" or "BeginHelloWorld", instead I see things like "HelloWorldRequest".

The asmx file contains only one line: -

<%@ WebService Language="vb" CodeBehind="~/App_Code/Service.vb" Class="Service" %>

Regards, Robert


1/5/2009 8:51:20 AM

Oh, now I see.  It sounds like you have both a "Web Service" and a "Service Reference".  The problem is that a "Service Reference" is meant to refer to a WCF service, not to a web service (confusing, I know).

Try deleting the Service Reference and adding a "Web Reference" in its place.

BTW, the code for your web service is in the code behind file, in App_Code/Service.vb



1/5/2009 9:15:57 AM

>The problem is that a "Service Reference" is meant to refer to a WCF service, not to a web service (confusing, I know).
Grrrr!   If this is the case, why couldn't they have labelled it "WCF Service Reference".    Actually I think I want to use WCF, but the book that I'm trying to follow, "ASP.NET 3.5" by George Shepherd, illustrates WCF in Ch 21 by reference to ASP.NET Services (Ch 20), so I was going to get a basic XML service running first.

How do I add a "Web Reference"?   When I right-click the VB program GDBChart (VS2008) there is no option for this, the options are: -
     Add (=> New Item, Existing Item, New Folder, Windows Form, User Control, Component, Module, Class) : this is oriented to adding components into the project, not references.
     Add Reference => the reference dialog, with tabs  .NET, COM, Project, Browse, recent:  this is oriented to adding namespaces
     Add Service Reference => a dialog that allows you to search for web references.  This appears to be the one we want, but this is what I did before.   I tried it again, and got the same result - I added a namespace allowing me to reference GDBWebService.HelloWorldRequest etc, but not a method "HelloWorld".        


1/5/2009 11:35:15 PM

Is your application an ASP.NET website?  For me, when I right click on my website project, I see "Add Web Reference..." and "Add Service Reference..."

Maybe it's different for your project type?  Which edition of VS 2008 are you using?

1/6/2009 12:08:30 AM

 VS2008, SP1.  My web projects are build with ASP .NET 3.5.

Like you, I see "add web reference" when I click on a web project, including the web service.  But I was trying to add the web service to GDBChart, a Windows program.  When I click on the Windows project there are only the other 3 Add options, as per my previous post.

1/6/2009 1:07:39 AM

Hi Robert,

Right click on Service References

Choose Add Service Reference - don't enter anything on that dialog but rather..

At the bottom of that dialog, choose "Advanced"

At the bottom of the next dialog choose "Add Web Reference"

Fill in your URL and select GO

Name your web service and then select "Add Reference"

You should then be able to do as you had expected.


1/7/2009 5:47:33 PM

Thanks CAnuszczyk.   I was able to get it going eventually with your help.

According to the dialog, I used this option to ensure compabiltity with ASP .Net 2.0  (I am using VS2008, with ASP .Net 3.5).  Why is this relevant?  After all, I should not have had a compability issue since both my test Windows program, and the test Web Service, were generated at the same time from VS2008.   

Thanks, Robert.

1/8/2009 10:10:31 AM

That, I don't know.  I just ran across the same problem and thought I would share it what I did find.

I'm still researching the whole thing and the changes made to VS 2008 for it.  I'll post when I find something.


1/10/2009 2:11:45 PM

Hi there,

I am using Visual Web Developer 2008, Express Edition but I cannot autogenerate the .DISCO and WDSL files.

I can create and test a simple WebService on the localhost.

Do I need to install and run IIS to be able to autogenerate .WSDL och .DISCO files? Or what is the problem?

Should it work work with the default unchanged HelloWorld webmethod? Somebody seemed to have problems with the namespaces, that prevented the autogeneration of the .disco file. Obviously, all "guidelines", "tutorials"  and "samples" assume some preconditions that I don't have.

1/20/2009 3:39:54 PM

Please start a new thread on this - your issue probably has nothing to do with the issue that started this thread.

John Saunders | MVP – Connected System Developer
1/20/2009 4:43:35 PM

Hi there,

 I am also stuck in the same problem. I am trying to consume a web service in a windows form.

 The service is running on an IIS server and when we access it in a browser, it shows the test page and respond in a usual way (The service is up and running).

 I am using VS2008 and create a windows project and try to add the service reference to the project. I have tried both the options separately

1- By simply adding a service reference

2- By going to the advanced option and choosing the Web service reference in the Dotnet 2.0 style.


The problem I am facing is, that most of the tutorials says that when you add a web service reference a proxy class will be automatically added to the project. So that we can create an object of the proxy class to use the web service.

The problem is that when we add the reference it does not create the proxy class with the name of the service "MyWebService" (MyWebService being the service to be used). There are some classes created in the new namespace, these are named like ...Request, ...RequestBody, ...Response, ...ResponseBody, and ...ServiceSoapClient.

 Now I am unable to understand which class to be used as a proxy to instantiate the object to use the web service. I think it is related to this thread.

 Kindly help find out, what I am missing.


 Uet Champ

5/4/2009 9:00:50 AM

Similar Artilces:

xml web service --uploading the file to the xml web service
how can we upload the file in the xml web service 1.i mean what will be the return value in the proxy class 2.and how am i going to send the file to the xml web service----regards Bipul Kumar Here are some links to articles that helped us get this done: Hope this helps....

How to call a .net web service from another .net web service?
Hi all,I have developed two asp .net web services using visual studio .net 2003.I wish to call one web service from another web service.I tried adding a web reference of the web service in another web service and was able to do so.but i m not able to access the web methods provided by the web servicecould you please suggest a way to go about itExpecting quick replyThanxCharmy try to make sure that you reference it in the web reference and call it properly this is sample  [WebMethod()] public double CalcDistance(int x1, int y1, int x2, int y2) { Calculator.Service1 calc = new...

Web service in .NET from Java Web Service
Hi there,I'm pretty new to .net (although i have years of experience with the old vb 6, access 2k, as well as java)... and need some with perhaps either some syntax or something.Here is the wsdl.<wsdl:definitions targetNamespace="">−<wsdl:types>−<schema targetNamespace="GetBookInfoByISBN">−<complexType name="BookInfoType">−<sequence><element maxOccurs="1" minOccurs="0" name="Title" nillable="true" type="xsd:string"/><element maxOccurs=&quo...

.NET web services Vs Java Web Services
Hello, does anyone know of a book or good source of information that compares .NET and Java Web Services? (I would like soemthing neutral if possible). I am thinking of approaching this subject for my dissertation? Many Thanks Rob Hi Rob, Last year I had to give a powepoint presentation on Web Services. I noticed some good books at barnes and noble that discussed the subject. These books were specific to Java and discussed Web Services in a very clear fashion. They gave some elementary examples that were easy to understand. I have not yet had the pleasure of creatin .NET Web Servi...

Web Service consuming other Web Services for caching purpose
Hello, I'm quite a newbie in Web Service programming. I'm using Visual Studio .NET 2003 on Windows XP Pro. I would like to write a Web Service on my local network that call Internet Web Service. Is there some writing rules for that or any tutorial. I want this new Web Service to cache the objects of other Web Services in order to reduce the response time. Furthermore, I wanted to test that with Babelfish Web Service on But when I make a Web Reference to the wsdl, I've a failure. VS success to access to the wsdl file but doesn't allow the web reference (&q...

New to web services...need help consuming web service
Hi guys. I am trying to use the NBA standing web service(developed by 4guysfromrolla) on my website and I cant seem to get it to work correctly. Its listed below. Tutorial is on the below page-- I made a web reference in my web project but when I go to create the object it gives me the Type "NBA.standings " not defined. I am copying the code exactly from the page. I put the imports at the top of the page. This is my code from the page load event Dim proxy As N...

Calling a Web Service from a Web Service
Hello,I was looking for some feedback on calling a web service from within a web service. I've heard that it's not good practice (or not possible). I have a scenario where I think it might make some sense.Within our infrastructure, we've created a web service that handles incoming updates on the statuses of all processes. This has proven to be a good thing since it allows applications to communicate across server to make status updates. It's also used by third party developers and applications to communicate with our infrastructure.Along these lines ... we are planning to create a new compon...

Is web services a part of web Service?
  I have a question: Is web services a part of web server?? And when the client calls web service, it means that client calls web server?? Or is it a different entity in itself which communicates separately both with client and server and acts as middleware application.. I am very confused.. Can someone explain me the architecture...??? Thanks..Dont forget to click "Mark as Answer" on the post that helped you.This credits the member,earns you a point & marks your thread as Resolved so that new users will know where to search for their queries. When you build and dep...

what are web services and what are the advantages of web services?
 Hello  i am new to this .net stuff and i was ask on the job interview what a web services is?and if i did not know given that i had a project ( as a project manager,  or a web developer)   what  is it? how do i start a >NET project on it? what are the main advantages is?  HOW DO I START THIS IN THE INTERVIEW>  and what basic books do i buy?   Hi There, There plenty of source on the net about webservice Definiton:

Web Site Project: How to configure web service URL in web.config (web service defined in a referenced DLL)
I have a web site that references a business logic DLL project. In the business logic project, there is a web service defined in its app.config file something like this: <applicationSettings>  <MyNamespace.BLL.Properties.Settings>    <setting name="MyNamespace_BLL_MyServer_ServiceName" serializeAs="String">    <value>http://blah.blah.blah.asmx</value>  </setting>  </MyNamespace.BLL.Properties.Settings></applicationSettings> When the web site is published, the web ...

create valid xml to send to web service based on the schema provided by web service
Problem: I have a web page which is being populated from a dataset containing multiple tables.  I now need to call a web service and send the majority of this data to be incorporate into a mainframe system.  I have been supplied with the schema that the web service will be using to validate the data.  I am new to web services and I am not sure how to take my existing dataset and transform it into an xml document that matches the schema I was provided with. There is a main schema with an element which is a custom complex type.  This custom type consists of an element whi...

Best Practice for .Net Web Service access to a Web Service on a Test and Production Servers
Hello All, What is the best way to control a .Net web service to be able to access a remote server for testing and then point to another remote server to access the web service in production? Do I need to generate and maintain 2 different proxy objects? TIA, Bob Bob // first create the proxy if not isvalid( i_service) then i_service = create fundtraderproxy_TradeServicesClient_BasicHttpBinding_ITradeServices end if ///You'll see code something like this in the constructor of your proxy //dynamically set the endpoint url with the user supplied value - //r...

Consuming .net xml web service in PHP
I have developed .net xml web service. I want a develope php client to access this web service. I dont have much knowledge about PHP. The web service i wrote accepts two string parameters FirstName and LastName, and returns string like Welcome (FisrstName)__(LastName) to web service. The sample php client code i am trying is as below: <?php require_once('nusoap.php'); $parameters = array ("FirstName"=>"Russel", "LastName"=>"Arnold"); // Create a new Soap object $soapclient = new soapclient('http://testwebservice/Servi...

New to web services, why does PB10 web service proxy wizard say there are no services?
here... oops typo... still doesn't show any services though... "Chance" <> wrote in message news:43b44cb3$1@forums-1-dub... > here... > > > Upgraded to 10.2x and now seems to be least it created the proxy. "Chance" <

What action by a web service requires an app to update their web reference to a Web Service
I create a web reference to a web service in my aspx web application which returns an XML object. If the owner of the web service makes a change to their object am I required to do an update web reference? What if I dont use the information from the new object? thanks Larry You should make the change only if the contract b/w the two has changed (e.g. parameters, return values), etc.-Mathew Nolton If the web service now returns a new element and my class reference doesn't match their new class ref...

Web resources about - Consuming a Web Service - what am I doing wrong? -

Tumblr : How do teenagers waste hours upon hours consuming Tumblr?
Answer (1 of 6): I am a teenager and also have a fascination with Tumblr. I will try my best to explain this from our perspective as teens. This ...

Are You Consuming Your Coffee Correctly? - YouTube
Have you been doing it wrong? The Scientific Smell Challenge: SUBSCRIBE (it's free!): GET ...

Briton sentenced to four years for consuming hashish in Dubai
... to having 6.4 grams of the drug for his personal use and he will be deported after serving his sentence. DUBAI // A Briton charged with consuming ...

Eating meat is hurting the environment - stop consuming so much, top US nutritional panel says
The country's foremost nutrition advisory panel is taking a stand against meat: Americans should eat less of it, top experts say, in order to ...

Teen love shown to be most consuming
BACK in 1965, Cat Stevens wrote The First Cut is the Deepest. It turns out he was right. New research from a joint American and Australian study ...

With legal marijuana, more little kids are accidentially consuming drug
Children's rates of exposure to marijuana have increased, even in US states where the drug has not been legalised.

Australians falling short on calcium intake and consuming too much sodium, survey finds
Australians aren't getting enough calcium from their food and most are consuming too much sodium, a new national survey has found.

Canadians consuming sky-high amounts of sodium, study finds
Canadians are consuming potentially dangerous amounts of sodium and Ottawa must take action to limit those levels, a leading expert on heart ...

13 Causes Of Insomnia, From Work Stress To What You're Consuming
After a long day, the only thing you want to do is crawl into bed for a good night's rest. Unfortunately, for 3.3 million Canadians, that isn't ...

Consuming Walker - AdPulp - AdPulp
It’s Sunday, which means it time to open The New York Times Magazine and read “Consumed,” the weekly column by Rob Walker. Today’s piece is about ...

Resources last updated: 11/22/2015 1:31:20 PM