Reputation: 698
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.
Upvotes: 23
Views: 63646
Reputation: 71
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.
Upvotes: 0
Reputation: 6881
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.
Upvotes: 1
Reputation: 12819
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
Upvotes: 23
Reputation: 698
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 :)
Upvotes: 2
Reputation: 1921
(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. ?
Upvotes: 12
Reputation: 1488
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/
Upvotes: 4