none
Optional SOAP Header in WSDL RRS feed

  • Question

  • I've authored a IWsdlExportExtension which adds a SOAP Header to the the operation description as follows.

    var headerDescription = new MessageHeaderDescription(AcpSoapOptions.Name, AcpSoapOptions.Namespace);           

    headerDescription.Type = typeof(AcpSoapOptions);           

    headerDescription.TypedHeader = false;           

    headerDescription.MustUnderstand = false; //This is an optional header           

    // Loop through all the operations defined for the contract and add custom SOAP header to the WSDL           

    foreach (OperationDescription op in context.Contract.Operations)           

    {                foreach (MessageDescription messageDescription in op.Messages)               

    {                    messageDescription.Headers.Add(headerDescription);               

    }           

    }


    The WSDL gets created with this header:

    <wsdl:input>       

    <soap:header message="tns:IXYZ_InputMessage_Headers" part="AcpSoapOptions" use="literal"/>               

    <soap:body use="literal"/>     

    </wsdl:input>


    However, I would like to set the WSDL 2.0 attribute wsdl:required="false" so that consumers of this service know that it is an optional header. So I'd like the WSDL to look like this:

    <wsdl:input>  
        <soap:header message="tns:IXYZ_InputMessage_Headers" part="AcpSoapOptions" use="literal" wsdl:required="false"/>    
        <soap:body use="literal"/>
    </wsdl:input>

    How can this be done in WCF?

    Thanks,

    Daniel


    Tuesday, August 23, 2016 2:50 PM

Answers

  • Hi Daniel,

    >> I would like to set the WSDL 2.0 attribute wsdl:required="false" so that consumers of this service know that it is an optional header.

    In my option, it is impossible. At present, WCF does not support WSDL 2.0. It supports WSDL 1.1. You could refer the link below for more information.

    # Web Services Protocols Interoperability Guide

    https://msdn.microsoft.com/en-us/library/ms734776.aspx?f=255&MSPPError=-2147217396

    In addition, there is no “wsdl:required” in Message Parts of WCF. We could not add this from MessageDescription. You could refer the link below for more information.

    # Message Parts

    https://msdn.microsoft.com/en-us/library/aa738723(v=vs.110).aspx

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Marked as answer by Daniel Bryars Wednesday, August 24, 2016 3:06 PM
    Wednesday, August 24, 2016 8:57 AM

All replies

  • Hi Daniel,

    >> I would like to set the WSDL 2.0 attribute wsdl:required="false" so that consumers of this service know that it is an optional header.

    In my option, it is impossible. At present, WCF does not support WSDL 2.0. It supports WSDL 1.1. You could refer the link below for more information.

    # Web Services Protocols Interoperability Guide

    https://msdn.microsoft.com/en-us/library/ms734776.aspx?f=255&MSPPError=-2147217396

    In addition, there is no “wsdl:required” in Message Parts of WCF. We could not add this from MessageDescription. You could refer the link below for more information.

    # Message Parts

    https://msdn.microsoft.com/en-us/library/aa738723(v=vs.110).aspx

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Marked as answer by Daniel Bryars Wednesday, August 24, 2016 3:06 PM
    Wednesday, August 24, 2016 8:57 AM
  • Thanks Edward

    I don't think WSDL 2.0 is very popular, the only reason I wanted it was to specify to a consumer of my service that a SOAP Header is optional.

    Thanks for you help.

    Regards,

    Daniel


    Wednesday, August 24, 2016 3:05 PM