Consuming a Web Service with .net


I created a wsdl from a service that has an xml template. I can run the service from IE and get the results. I add the web reference to my .net project and try to create a new instance but it does not work.

Dim myNewInstance as New MyProject.localhost.(?)
When I create web services from .net the ? is usually the class. Then I can call the methods → myNewInstance.getdata()

The wsdl does not seem to contain all the information to create an instance. Can anyone help?



Did you use the .Net command line tools to generate a proxy class from your WSDL? If so, did that utility complete successfully?

See this article on using the Amazon web services from .Net for some ideas.


I did run the wsdl.exe and created the .vb class. Yesterday I just tried to set a web reference and that was my problem. It looks like the webMethods service returns a System.Xml.XmlElement from the XML Template.

This is my code:
Dim wmWsdl As New elc_common_errorHandling_utilsService
Dim returnData As System.Xml.XmlElement
returnData = wmWsdl.getErrorInterface()
Dim reader As XmlNodeReader = New XmlNodeReader(returnData)
Dim ds As DataSet
DataGrid2.DataSource = ds

The error is “The XML declaration is unexpected. Line 2, position 3.”


Are you using Soap-RPC or Soap-Msg (document/literal)? What are the input and output signatures of your service? Can you post the WSDL as an attachment?

BTW, I added the code highlighting to your last post using the [highlight=vb] tags.


I am using the protocol http-get via http. No input or output elements I just call a JDBC adapter that returns rows from a database. The service returns an xml stucture with the data from the pipeline created my the xml template. I can invoke the service from a browser and see the xml and the data.

How do I post the .wsdl attachment?


Hmmm. I’m not sure .Net can consume a WDSL that uses the HTTP-GET port. It’s certainly not very common.

You could try generating the WSDL as soap-rpc. That is more common but not nearly as interoperable as document/literal (aka soap-msg).

You can attach things to your posts by swithcing to the advanced mode editor (click the “Go Advanced” button) and then using the attachment icon.


I should stay away from HTTP-GET and HTTP-POST?

Yes, those are less interopeable and less-well supported by other tool vendors than soap-msg and soap-rpc.

The document/literal style of soap messages is the most standard and most interoperable.

Document/literal or rpc/literal style and use attributes are mandantory for compliance with the Web Services Interoperability (WS-I) Basic Profile 1.0.

I’m not saying you can’t get one of the others to work, but you should expect to have interoperability issues with other tool vendors.

Search the Web Services / Soap forum for “document / literal” for information on how to create the wrapper service you need to expose a given Flow or Java service as a document/literal web service.


thank you.



I found this today in the Building Interoperable Web Services WS-I Basic Profile 1.0 publication from Microsoft Developer Network (MSDN).

Hi Mark,

I will try using SOAP-Msg. Thanks for the article. I created a test service to sum 2 numbers and return the total and used SOAP-RPC to create the webservice. I used the wsdl to create the proxy adding username and password but the service said access denied in webMethods admin console. I just changed the service to anonymous and it worked. The same method did not work for a service that returns an xml template vs. output string. The instance of the class.method in .net does not let me assign the web service return value (xml) scrolling over the instance it says “Expression does not contain a value”. Still trying!

Again, thanks for your time and effort.


By default, IS requires clients to authenticate (login) before they can invoke a service. This requires all web services consumers to at least use Basic Authentication to provide a set of credentials (username and password). When the request is coming in via HTTP, the credentials are passed in HTTP header variables (a standard part of the HTTP protocol).

Each programming language has its own set of methods for setting the values of HTTP header variables. I don’t recall the methods for VB .Net or C# off of the top of my head, but you need to use then to set the authentication type to “Basic” and then add the username and password to the credentials.

Perhaps one of our .Net developers can help or I’m sure you can find it in the docs. In the meantime, in Development only, you can set the ACL to anonymous as you have done to workaround this, just be sure to not promote this beyond your development environment.