Display a WSDL file for a WCF web service

I have a group of five web services running on an IIS server in the cloud.  The services are working well, and I have a web client accessing these services. Now I am trying to create some documentation for users.  Of course I want to include the WSDL file in this doc, but am unable to produce it.

I have httpGetEnabled=true
In the protocols section I have <add name = "Documentation">
I am trying to display the wsdl by putting into a browser the endpoint that I used in the ServiceReference with a postfix of /?wsdl (also w/o the '/')
Error is 500 Internal server error
I also found wsdl.exe and tried to use that to generate the file.  Access refused.

What am I missing, folks?
Mark KleinAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
In the past, I have extended a web method that takes the service contract, and generates an HTML response, that you can view in the browser.  Since it was internal to the web service, it had access to the classes, and methods.
Mark KleinAuthor Commented:
but how do I get the WSDL file?
Bob LearnedCommented:
Oh, and I don't worry about the WSDL, as the HTML response shows all the same information as the WSDL, which is more difficult to read.
Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.

Mark KleinAuthor Commented:
Maybe for you, but everything I read says that good documentation of a web service includes the WSDL file, so I still want to include it. Can you help?
Bob LearnedCommented:
Fair enough...I may be able to help, let's see...

A WCF service provides that WSDL when you append ?WSDL to the URL, but not by default.  I am assuming that you are trying to provide the WSDL through a different mechanism, such as a web method.

Also, I am not sure what the <add name = "Documentation"> is supposed to do.  From what I know about the protocols, it is more about something like this (but this doesn't sound related to that):

<protocolMapping>
        <add scheme="http" binding="basicHttpBinding"/>
        <add scheme="net.tcp" binding="netTcpBinding"/>
        <add scheme="net.pipe" binding="netNamedPipeBinding"/>
        <add scheme="net.msmq" binding="netMsmqBinding"/>
</protocolMapping>

Open in new window


In order to provide WSDL, you need to expose service metadata (that might be what you meant by "I have httpGetEnabled=true"):

<serviceBehaviors>
  <behavior name="myServiceBehaviour">
    <serviceMetadata httpGetEnabled="true" />
  </behavior>
</serviceBehaviors>

Open in new window


Interesting articles, that may or may not help:

WCF and WSDL
http://mikehadlow.blogspot.com/2007/04/wcf-and-wsdl.html

Resolving mutipart WSDL documents with DiscoveryClientProtocol
http://mikehadlow.blogspot.com/2007/04/resolving-mutipart-wsdl-documents-with.html
Mark KleinAuthor Commented:
Thanks for pitching in.  No, I am not trying another web method unless I have to https://msdn.microsoft.com/en-us/library/ms242494%28v=vs.90%29.aspxdo so.  Want to use the ?WSDL mechanism if possible, but it's not working.  See
https://msdn.microsoft.com/en-us/library/ms242494%28v=vs.90%29.aspx
and
https://msdn.microsoft.com/en-us/library/ms242476%28v=vs.90%29.aspx

Here is the service behaviors section of my web.config: (seems to conform to what is suggested in your link)
<serviceBehaviors>
        <behavior name="ArrowsServiceBehavior">
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" httpGetUrl=""/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>

Open in new window


I'm trying for the plain vanilla approach: having WCF generate the WSDL file
Bob LearnedCommented:
I created a test WCF service, and when I ran the web service, I got a page that suggested that I use this URL for the WSDL:

http://localhost:5201/Service1.svc?singleWsdl

I guess that since it has been quite a while since I have used WCF (use Web API mostly), that one slipped out of my memory banks.

WCF page when service is started in the IDE
Mark KleinAuthor Commented:
ok, some progress.
yeah, that was where I started and that was the link I got.  But using the link, nothing happened.  So I tried to repeat the process just now and got a different error msg and some useful information.  I have a malformed web.config in the <webServices> part.
Here are the error messages:

  The configuration section 'webServices' cannot be read because it is missing a section declaration

Here's the malfunctioning  code per the err msg:

Config Source:
    9:   </connectionStrings>
   10:   <webServices>
   11:     <protocols>

and here is a fragment of my web.config:
 </connectionStrings>
  <webServices>
    <protocols>
      <add name="Documentation" />
    </protocols>
  </webServices>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>

Do I possibly have the <webServices> section in the wrong place?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mark KleinAuthor Commented:
Success!
Moved the <webServices> section inside System.web
Repeated process and got the WSDL file.
Many thanks.
Bob LearnedCommented:
According to this reference, that section should be under the <system.web> section:

<webServices> Element
https://msdn.microsoft.com/en-us/library/cs8x2624.aspx

<configuration>
  <system.web>
    <webServices>
Mark KleinAuthor Commented:
struggled through this myself
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
WCF

From novice to tech pro — start learning today.