Hide REST endpoint from MEX/WSDL in WCF?

You can get a copy of the WSDL, manually edit it to remove unwanted artifacts, and store it in a known location. Once you have the version of your WSDL that removes unwanted artifacts, you can redirect the? Wsdl query to that location: behaviors> You have to be careful about what you edit.

If you change critical aspects of the contract, WCF may not be able to handle messages from clients generated from it. Removing an endpoint is generally not a big deal, however changing names for bindings, operations, message types, etc. Can cause problems You also need to be aware of imports. The WSDL generated by WCF usually defines the endpoints, then imports another .

Wsdl that defines the actual service contract. The service contract wsdl in tern usually imports several . Xsd files that define your message and data types.

You will need to make sure you have copies of these uploaded relative to the root . Wsdl, and that you update the import elements to reference them appropriately Another issue with this is that you are now manually controlling your contract...which means if you change it, you have to edit it again and replace it on whatever site you are hosting the . Wsdl file.

Now, a properly designed contract should NEVER change, as that breaks one of fundamental SOA rules about web services. However, it appears that you are doing code-first development, so its something to be aware of.

You can get a copy of the WSDL, manually edit it to remove unwanted artifacts, and store it in a known location. Once you have the version of your WSDL that removes unwanted artifacts, you can redirect the? Wsdl query to that location: A couple caveats about this solution.

You have to be careful about what you edit. If you change critical aspects of the contract, WCF may not be able to handle messages from clients generated from it. Removing an endpoint is generally not a big deal, however changing names for bindings, operations, message types, etc.Can cause problems.

You also need to be aware of imports. The WSDL generated by WCF usually defines the endpoints, then imports another . Wsdl that defines the actual service contract.

The service contract wsdl in tern usually imports several . Xsd files that define your message and data types. You will need to make sure you have copies of these uploaded relative to the root .

Wsdl, and that you update the import elements to reference them appropriately. Another issue with this is that you are now manually controlling your contract...which means if you change it, you have to edit it again and replace it on whatever site you are hosting the . Wsdl file.

Now, a properly designed contract should NEVER change, as that breaks one of fundamental SOA rules about web services. However, it appears that you are doing code-first development, so its something to be aware of.

The manual solution will work, however as you point out, it's far from ideal. For better or worse, this service will evolve over time with new methods added periodically, so the contract WILL change. I'm looking for a more automated solution, so I don't have to remember to muck with the WSDL on every service enhancement.

– WayneC Mar 2 '10 at 5:52 1 There is no reason you couldn't automate the process. It is all XML, and it should be easy enough to write some process, maybe even a powershell script, that is run as part of your deployment process. It could pull down all the files from the normal?

Wsdl query, use XPath to find and remove the required element, and deploy all the . Wsdl and . Xsd files.

Finally, it could update the configuration automatically to add the element to your binding behavior. – jrista Mar 2 '10 at 6:06.

It would be nice if there was an attribute to decorate the endpoint so that it is hidden from mex/wsdl generation in future versions of WCF for exactly this reason (hiding restful services from soap clients).

Found a decent way to do this using an IWsdlExportExtension. There's probably a more robust/reusable way to do this, but this solution requires the convention of all REST endpoints to be named "REST". Below is the relevant part of an Endpoint behavior attached to all REST endpoints: public void ExportEndpoint(WsdlExporter exporter, WsdlEndpointConversionContext context) { // Remove all REST references (binding & port) from SOAP WSDL foreach (ServiceDescription wsdl in exporter.

GeneratedWsdlDocuments) { // Remove REST bindings foreach (Binding binding in wsdl. Bindings) { if (binding. Name == "REST") { wsdl.Bindings.

Remove(binding); break; } } // Remove REST ports foreach (Service service in wsdl. Services) { foreach (Port port in service. Ports) { if (port.Name == "REST") { service.Ports.

Remove(port); break; } } } } }.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions