Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm troubling into an issue... I'm trying to find a way to generate a single wsdl document from my WCF service, i.e. without any link to external documents. I've used FlatWsdl to remove all xsd:import links, bou my generated wsdl still contains a link to an external wsdl document via a wsdl:import declaration:

<wsdl:import namespace="http://myurl/mynamespace"  
             location="http://myserver/myservice.svc?wsdl=wsdl0"/>

This document actually contains all inlined xsd schemas, so... there's a way to inline also this external wsdl document, in order to have a single wsdl?

Thanks a lot for any kind of help.

share|improve this question

7 Answers 7

up vote 10 down vote accepted

(EDIT: Previous answer about FlatWSDL deleted, because as you pointed out it was about eliminating xsd:import not wsdl:import.)

Look at this blogpost: Control generated WSDL in WCF

"... There is always one WSDL generated for one target namespace URI ..."

Do you have different namespace for ServiceContract, DataContract, ServiceBehavior, etc. ?

share|improve this answer

You can now do this natively in .net 4.5 (beta). There is an option (?singleWsdl instead of ?wsdl) for telling the service to output everything in a single wsdl document. More info on the new stuff here: http://msdn.microsoft.com/en-us/library/dd456789(v=vs.110).aspx

share|improve this answer

You could also use the WCFExtras project it has an extension to create a single WSDL-file.

WCFExtras

A collection of useful WCF extensions including Soap Header support, WSDL documentation and more.

The WCF platform is very extensible and allows you to easily add features that are not part of the core product. This project contains some extensions I needed in a WCF based project:

  • SOAP Header support for WCF Adding WSDL
  • Documentation from Source Code XML Comments
  • Override SOAP Address Location URL
  • Single WSDL file for better compatibility with older SOAP tools.

http://wcfextras.codeplex.com/

share|improve this answer

You need to add some extra behaviours etc.

See these articles here:

http://my-tech-talk.blogspot.com/2008/07/adding-flatwsdl-to-wcf-webservice.html

http://blogs.thinktecture.com/cweyer/archive/2007/05/10/414840.aspx

There are several different ways of achieving this.

Marc

share|improve this answer

my problem was in endpoint definitions, that are in tempuri.org namespace adding bindingNamespace to endpoint declarations fix my problem. thanks to all for help :)

share|improve this answer

This is a late answer, but I had the same problem with a few of our WCF services. If you're on .NET 4.5, like the earlier answer, use ?singleWSDL, but if you're not targeting .NET 4.5 then I added the following to my web.config to fix the issue...

<useRequestHeadersForMetadataAddress>
  <defaultPorts>
    <add port="80" scheme="http" />
    <add port="443" scheme="https" />
  </defaultPorts>
</useRequestHeadersForMetadataAddress>

This goes in your behavior. That way I didn't have to flatten the WSDL because all references were to MyURL instead of MyServer.

Hope this helps others with a similar issue.

share|improve this answer

In addition to Jim's answer above, if you're using C# code to configure a WCF ServiceHost directly:

using System.ServiceModel.Configuration;

and when setting up your ServiceHost:

UseRequestHeadersForMetadataAddressBehavior urh = new UseRequestHeadersForMetadataAddressBehavior();
serviceHost.Description.Behaviors.Add(urh);

I struggled to find this information online, as simple as it is. Hopefully helps someone in a similar situation.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.
{"cc_re__cc_re__cc_by_sa_3_0": ["                  <li><a href=\"//area51.stackexchange.com\" title=\"proposing new sites in the Stack Exchange network\">Area 51</a></li>\r\n                        <li><a href=\"//careers.stackoverflow.com\">Stack Overflow Careers</a></li>\r\n                    \r\n                </ol>\r\n            </td>\r\n    </tr>\r\n</table>\r\n                </div>\r\n            </div>\r\n\r\n            <div id=\"copyright\">\r\n                site design / logo &#169; 2015 stack exchange inc; user contributions licensed under <a href=\"http://creativecommons.org/licenses/by-sa/3.0/\" rel=\"license\">cc by-sa 3.0</a> \r\n                with <a href=\"http://blog.stackoverflow.com/2009/06/attribution-required/\" rel=\"license\">attribution required</a>\r\n            </div>\r\n            <div id=\"svnrev\">\r\n                rev 2015.5.1.2550\r\n            </div>\r\n            \r\n        </div>\r\n    </div>\r\n    <noscript>\r\n        <div id=\"noscript-warning\">Stack Overflow works best with JavaScript enabled<img src=\"http://pixel.quantserve.com/pixel/p-c1rF4kxgLUzNc.gif\" alt=\"\" class=\"dno\"></div>\r\n    </nosc"], "copyright__copyright__copyright": [" your ServiceHost:\n\nUseRequestHeadersForMetadataAddressBehavior urh = new UseRequestHeadersForMetadataAddressBehavior();\nserviceHost.Description.Behaviors.Add(urh);\n\nI struggled to find this information online, as simple as it is. Hopefully helps someone in a similar situation.\n\nshare|improve this answer\n\nYour Answer\n\n\u00a0\ndiscard\n\nBy posting your answer, you agree to the privacy policy and terms of service.\n\nNot the answer you're looking for? Browse other questions tagged or ask your own question."]}