1

I have been given a WSDL with all the method requests and responses, and all the objects I'll need to use for creating a few web methods.

I've successfully added the WSDL as a "service reference" and I can see the methods and structures and can instantiate them. It all seems to be there. But, I have a problem: the project won't build after I add the WSDL. Here's the error message I am getting when Visual Studio tries to compile Reference.cs:

"Error 2 The type name 'ServiceReference1' does not exist in the type 'WSPELab.WSPELab' C:\Users\JJ\Documents\Visual Studio 2008\Projects\WSPELab\WSPELab\Service References\ServiceReference1\Reference.cs 21 111 WSPELabSLN

Is it possible that I am receiving this error message because of a namespace error on my part?

Finally, one additional question: With the WSDL added, can I use the structures it contains directly? Or are they just "listings" for me to implement?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Johnny
  • 169
  • 1
  • 2
  • 8
  • Possibly related: [Error accessing a WCF service from a client](http://stackoverflow.com/q/31357502/1497596) – DavidRR Nov 10 '15 at 13:25

1 Answers1

3

A WSDL is a machine-readable file that describes the methods and types exposed by a web service. Many IDEs, including Eclipse and Visual Studio, can import these and create programming language classes that match the definitions given in the WSDL.

For example, importing a WSDL in a Visual Studio C# project will create a Reference.cs file that contains these definitions. You have to instantiate and call these definitions the same as you do for any classes.

var webServiceReference = new WsdlNamespace.ClassDefinedInWsdl();
WsdlNamespace.ParamClassDefinedInWsdl dataToGet;
WsdlNamespace.ReturnCodeTypeDefinedInWsdl retCode = webServiceReference.MethodDefinedInWsdl("params expected by method", out dataToGet);
if (retCode == WsdlNamespace.ReturnCodeValueMeaningAllIsWell)
{
    // use properties of dataToGet
}

Giving any more detail would require showing us the actual WSDL.

Dour High Arch
  • 21,513
  • 29
  • 75
  • 90
  • Thanks! I was going in the right direction but there was some weird namespace error. I started a new project and added the reference, I can now use all the existing classes. Thanks again! – Johnny Jun 17 '10 at 10:23