Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

IWsdlExportExtension::ExportEndpoint Method (WsdlExporter^, WsdlEndpointConversionContext^)

 

Writes custom Web Services Description Language (WSDL) elements into the generated WSDL for an endpoint.

Namespace:   System.ServiceModel.Description
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

void ExportEndpoint(
	WsdlExporter^ exporter,
	WsdlEndpointConversionContext^ context
)

Parameters

exporter
Type: System.ServiceModel.Description::WsdlExporter^

The WsdlExporter that exports the endpoint information.

context
Type: System.ServiceModel.Description::WsdlEndpointConversionContext^

Provides mappings from exported WSDL elements to the endpoint description.

Implement the ExportEndpoint method to modify the WSDL exported for an endpoint. This method is called after the contract has been exported by ExportContract.

The following code example shows an IWsdlExportExtension that adds custom documentation attributes to the WSDL file as WSDL annotations.

  public void ExportContract(WsdlExporter exporter, WsdlContractConversionContext context)
{
   Console.WriteLine("Inside ExportContract");
if (context.Contract != null)
{
     // Inside this block it is the contract-level comment attribute.
     // This.Text returns the string for the contract attribute.
     // Set the doc element; if this isn't done first, there is no XmlElement in the 
     // DocumentElement property.
     context.WsdlPortType.Documentation = string.Empty; 
     // Contract comments.
     XmlDocument owner = context.WsdlPortType.DocumentationElement.OwnerDocument;
     XmlElement summaryElement = Formatter.CreateSummaryElement(owner, this.Text); 
     context.WsdlPortType.DocumentationElement.AppendChild(summaryElement);

     foreach (OperationDescription op in context.Contract.Operations)
     {
       Operation operation = context.GetOperation(op);
       object[] opAttrs = op.SyncMethod.GetCustomAttributes(typeof(WsdlDocumentationAttribute), false);
       if (opAttrs.Length == 1)
       {
         string opComment = ((WsdlDocumentationAttribute)opAttrs[0]).Text;

         // This.Text returns the string for the operation-level attributes.
         // Set the doc element; if this isn't done first, there is no XmlElement in the 
         // DocumentElement property.
         operation.Documentation = String.Empty;

         // Operation C# triple comments.
         XmlDocument opOwner = operation.DocumentationElement.OwnerDocument;
         XmlElement newSummaryElement = Formatter.CreateSummaryElement(opOwner, opComment);
         operation.DocumentationElement.AppendChild(newSummaryElement);

         // Get returns information
         ParameterInfo returnValue = op.SyncMethod.ReturnParameter;
         object[] returnAttrs = returnValue.GetCustomAttributes(typeof(WsdlParameterDocumentationAttribute), false);
         if (returnAttrs.Length == 1)
         {
           // <returns>text.</returns>
           XmlElement returnsElement = 
             Formatter.CreateReturnsElement(
               opOwner,
               ((WsdlParameterDocumentationAttribute)returnAttrs[0]).ParamComment
             );
           operation.DocumentationElement.AppendChild(returnsElement);
         }

         // Get parameter information.
         ParameterInfo[] args = op.SyncMethod.GetParameters();
         for (int i = 0; i < args.Length; i++)
         {
           object[] docAttrs 
             = args[i].GetCustomAttributes(typeof(WsdlParameterDocumentationAttribute), false);
           if (docAttrs.Length != 0)
           {
             // <param name="Int1">Text.</param>
             XmlElement newParamElement = opOwner.CreateElement("param");
             XmlAttribute paramName = opOwner.CreateAttribute("name");
             paramName.Value = args[i].Name;
             newParamElement.InnerText 
               = ((WsdlParameterDocumentationAttribute)docAttrs[0]).ParamComment;
             newParamElement.Attributes.Append(paramName);
             operation.DocumentationElement.AppendChild(newParamElement);
           }
         }
       }
     }
   }

.NET Framework
Available since 3.0
Return to top
Show:
© 2017 Microsoft