Condividi tramite


WsdlContractConversionContext Classe

Definizione

Passato a utilità di esportazione e importazione WSDL personalizzate per abilitare la personalizzazione dei processi di esportazione e importazione dei metadati per un contratto.

public ref class WsdlContractConversionContext
public class WsdlContractConversionContext
type WsdlContractConversionContext = class
Public Class WsdlContractConversionContext
Ereditarietà
WsdlContractConversionContext

Esempio

Nell'esempio di codice seguente viene illustrato l'uso di WsdlContractConversionContext per aggiungere annotazioni WSDL personalizzate ai metadati esportati usando le WsdlPortType proprietà e Contract .

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);
                }
            }
        }
    }
}

Commenti

Utilizzare l'oggetto WsdlContractConversionContext per esaminare e modificare gli elementi da convertire in o da WSDL.

Quando si esportano metadati, un WsdlContractConversionContext oggetto viene passato ai ExportContract metodi e ExportEndpoint . Utilizzare i vari metodi e proprietà per ottenere oggetti metadati che è possibile utilizzare per esaminare e modificare per modificare il linguaggio WSDL pubblicato.

Quando si importano metadati, un WsdlContractConversionContext oggetto viene passato ai ImportContract metodi e ImportEndpoint . Utilizzare i vari metodi e proprietà per ottenere oggetti di metadati che è possibile usare per esaminare e modificare i metadati importati.

Proprietà

Nome Descrizione
Contract

Ottiene l'oggetto ContractDescription da esportare o importare.

WsdlPortType

Ottiene l'oggetto PortType che rappresenta il contratto.

Metodi

Nome Descrizione
Equals(Object)

Determina se l'oggetto specificato è uguale all'oggetto corrente.

(Ereditato da Object)
GetFaultDescription(OperationFault)

Restituisce la descrizione dell'errore specificato.

GetHashCode()

Funge da funzione hash predefinita.

(Ereditato da Object)
GetMessageDescription(OperationMessage)

Restituisce la descrizione del messaggio specificato.

GetOperation(OperationDescription)

Restituisce l'operazione per la descrizione dell'operazione specificata.

GetOperationDescription(Operation)

Restituisce la descrizione dell'operazione associata all'operazione.

GetOperationFault(FaultDescription)

Restituisce l'oggetto OperationFault per l'oggetto richiesto FaultDescription.

GetOperationMessage(MessageDescription)

Ottiene un OperationMessage oggetto per l'oggetto specificato message che rappresenta un tipo di messaggio passato dall'azione di un servizio Web XML.

GetType()

Ottiene il Type dell'istanza corrente.

(Ereditato da Object)
MemberwiseClone()

Crea una copia superficiale del Objectcorrente.

(Ereditato da Object)
ToString()

Restituisce una stringa che rappresenta l'oggetto corrente.

(Ereditato da Object)

Si applica a