How to control the WSDL created by WCF

Szendefy Áron 1 Reputation point
2020-05-19T14:23:23.467+00:00

Dear Forum,

Can you please help.

I've got a Visual Studio WCF project (.NET: 4.7.2, Language: C#) where I am using [ServiceContract], [DataContract] and [MessageContract] attributes to generate WSDL from the classes implementing the services (see attached file).

The WSDL generated by WCF contains the following unnecessary parts, items. How can I get rid of these?

  1. Some XML namespace-es which are not used in the WSDL (eg. xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd")
  2. A complete <xs:schema> section that defines the base types as elements.
  3. Some types are also defined as elements though the SOAP message does not contain them as elements (eg. type="q2:AsyncReportRequest")
  4. The SOAP message elements defined by [MessageBodyMember] attributes inside a [MessageContract] decorated class are defined as optional in the WSDL (Eg. <xs:element minOccurs="0" name="callContext" nillable="true" type="q1:callContext">). I found no option on the attributes to specify "required".

I've already studied all properties of the decorating attribute classes and found no solution.
I've also looked at the possibilities of IWsdlExportExtension to extend WCF on the WSDL export functionality but I couldn't find a solution for changing the way WCF handles and generates these parts. I could only find description for adding additional information to the WSDL by defining custom attributes.

Thank you for helping, regards,
Áron

ps. I put the tag windows-runtime because wcf is not available in the tags list. Actually not many things are available, why is that?

8359-dwhhorizontaszinkronriportlekerdeze1-localhost-ws.xml

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
36,258 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Richard Zhang-MSFT 6,936 Reputation points
    2020-05-20T03:17:48.613+00:00

    Hello,

    Welcome to Microsoft Q&A!

    Currently, Microsoft Q&A is under a public preview. Your issue about WCF is not supported right now. But there is a better place for asking questions about WCF, you could ask about this issue in WCF Data Service.

    Thank you.

    0 comments No comments