By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,701 Members | 1,966 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,701 IT Pros & Developers. It's quick & easy.

How to disable WSDL generation in web.config file

P: n/a
I am trying to eliminate the capability of displaying the details of a web
service by disabling WSDL generation in the web.config file. I have made the
following changes to the web.config:

<webServices>
<wsdlHelpGenerator href="helpPage.aspx"/>
<protocols>
<remove name="Documentation" />
</protocols>
</webServices>

My goal is to have simple text displayed when the user goes to the web page
i.e. enters https:/MyWebPage/WebPage.asmx. I want to disable the ability to
display the web details i.e. the user enters
https:/MyWebPage/WebPage.asmx?wsdl as this displays all the details of my web
service; which I want to hide.

Everything works fine if I do not have the statement
<remove name="Documentation" />
in the web.config file. However, when I add that line in an attempt to hide
the information displayed when the user adds the ?WSDL; I get the runtime
error below. How do I remove the ability to display the WSDL information
while still allowing my web site to display a help page? Why am I getting an
error?

Runtime Error
Description: An application error occurred on the server. The current custom
error settings for this application prevent the details of the application
error from being viewed remotely (for security reasons). It could, however,
be viewed by browsers running on the local server machine.

Details: To enable the details of this specific error message to be viewable
on remote machines, please create a <customErrorstag within a "web.config"
configuration file located in the root directory of the current web
application. This <customErrorstag should then have its "mode" attribute
set to "Off".

<!-- Web.Config Configuration File -->

<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</
--
Thank you.
Sep 25 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hello John,

From your description, I understand you're going to prevent the
autogenerated WSDL document( **.asmx?WSDL ) from being visited by users but
still allow the display of the default webservice main helper page, correct?

As for the exception you encountered, it is an expected one and you haven't
missed any particular things. Actually, the cause of the problem is that
the "Documentation" protocol you configure through the (<protocols>
collection) controls both the webservice helper document page and the WSDL
document's generation, therefore, if you remove it from the <protocols>
collection, the end user will no longer be able to visit the .asmx or
..asmx?WSDL from browser.

So far based on my research, if we want to display customized content for
our asmx webservice, we still have to leave the "documentation" protocol
enable(do not remove it from the <protocolscollection). And use the
<wsdlHelperGenerator to configure a custom helper page.

As for the WSDL document(display through ".asmx?WSDL"), we can not
completely disable it , however, there is a means that we configure our
webservice/webmethod to use a custom WSDL document(by specifying a
webservice binding). e.g.
====================
[WebServiceBinding( Name="MyBinding", Location = "CustomWSDLPage.aspx")]
public class SimpleService : System.Web.Services.WebService
...............
[SoapDocumentMethod(Binding="MyBinding")]
public string HelloWorld()
{
...........
====================

Thus, the original WSDL document(display through .asmx?WSDL) will display
few WSDL elements(only the sevice address ) and will redirect the service
description to our custom location. You can have a look at the following
article for the detailed description on using a custom WSDL document for
ASP.NET webservice.

#Using a Custom WSDL File in ASP.NET Web Services
http://pluralsight.com/blogs/craig/a.../15/17482.aspx

Hope this helps some. Please feel free to let me know if there is anything
else we can help.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Sep 26 '06 #2

P: n/a
To confirm my understanding; if leave the <remove name="Documentation" />
tag; my web service should still work, but it will display the error message
I am seeing. For now, an error message is fine; as long as the web service
still works. It seems to work, just want to confirm I am not missing any
potential problems. The only problem that I know of is that a program cannot
"discover" the web service since I removed the documentation. Since the
programs that access the web service are already compiled, they don't need to
discover the service; they already know how to interact with it.
--
Thank you.
"Steven Cheng[MSFT]" wrote:
Hello John,

From your description, I understand you're going to prevent the
autogenerated WSDL document( **.asmx?WSDL ) from being visited by users but
still allow the display of the default webservice main helper page, correct?

As for the exception you encountered, it is an expected one and you haven't
missed any particular things. Actually, the cause of the problem is that
the "Documentation" protocol you configure through the (<protocols>
collection) controls both the webservice helper document page and the WSDL
document's generation, therefore, if you remove it from the <protocols>
collection, the end user will no longer be able to visit the .asmx or
.asmx?WSDL from browser.

So far based on my research, if we want to display customized content for
our asmx webservice, we still have to leave the "documentation" protocol
enable(do not remove it from the <protocolscollection). And use the
<wsdlHelperGenerator to configure a custom helper page.

As for the WSDL document(display through ".asmx?WSDL"), we can not
completely disable it , however, there is a means that we configure our
webservice/webmethod to use a custom WSDL document(by specifying a
webservice binding). e.g.
====================
[WebServiceBinding( Name="MyBinding", Location = "CustomWSDLPage.aspx")]
public class SimpleService : System.Web.Services.WebService
...............
[SoapDocumentMethod(Binding="MyBinding")]
public string HelloWorld()
{
...........
====================

Thus, the original WSDL document(display through .asmx?WSDL) will display
few WSDL elements(only the sevice address ) and will redirect the service
description to our custom location. You can have a look at the following
article for the detailed description on using a custom WSDL document for
ASP.NET webservice.

#Using a Custom WSDL File in ASP.NET Web Services
http://pluralsight.com/blogs/craig/a.../15/17482.aspx

Hope this helps some. Please feel free to let me know if there is anything
else we can help.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights
Sep 26 '06 #3

P: n/a
Thanks for your reply John,

Yes, you're right, when you have removed the <remove name="Documentation"
/element, it only disable the documentation(main helper page and WSDL
page) from displaying, and the webservice function is still working.
Actually, webservice function call is controlled by those message
protocols(such as HttpSoap, HttpSoap12.....).

Also, the reason why we'll get "can not discover the service" on client
when generate proxy is because webservice client proxy generation will need
to discover the servcie description(WSDL) first. Thus, if the service
description is disabled( like removing the "documentation" protocol in our
scenari), we'll get such error.

If there is anything else you wonder, please feel free to let me know.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
Sep 27 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.