Search code examples
.netvisual-studioweb-serviceswsdl

Why can't I generate client code from this WSDL file in Visual Studio?


I'm trying to code a .NET client for the cleverreach API ( WSDL file: http://api.cleverreach.com/soap/interface_v4.php?wsdl , documentation at http://api.cleverreach.com/soap/interface_v4.php ) in Visual Studio 2010.

The problem is that no matter what I do there doesn't seem any way to create C# code for this API.

I've tried both ways - adding a service reference and a web reference. In both ways there was no code generated for the methods of the API (something like createList or addBatch).

I've also tried using the command line instead:

svcutil.exe /language:cs /out:GeneratedProxy.cs /config:app.config http://api.cleverreach.com/soap/interface_v4.php?wsdl

This just gives me an error message:

Generating files... Warning: No code was generated. If you were trying to generate a client, this could be because the metadata docu ments did not contain any valid contracts or services or because all contracts/services were discovered to exist in /reference assembl ies. Verify that you passed all the metadata documents to the tool.

When I look at the WSDL file in a web browser, the methods I am looking for (createList for instance) are mentioned. So I am not sure what is going on.

What I'd like to know:

  • Why can't Visual Studio create the client-side code for this web service?
  • How can I work around the problem?

Thanks,

Adrian


Solution

  • Most likely, the reason you didn't get any code is because the WSDL is not valid. Simply opening it in XMLSpy tells the story:

    Invalid XML schema: 'Attribute 'firstname' is not allowed in element <xsd:element>'
    

    That's on

    <xsd:element name="firstname" type="xsd:string" firstname="registered"/>
    

    You might want to contact the vendor and ask them what they were thinking.