Ejemplo n.º 1
0
        private MessageDescription CreateParameterMessageDescription(ContractDescription contract, ParameterInfo[] parameters, Type returnType, ICustomAttributeProvider returnCustomAttributes, System.ServiceModel.Description.XmlName returnValueName, string methodName, string ns, string action, MessageDirection direction, bool allowReferences)
        {
            MessageDescription description = new MessageDescription(action, direction)
            {
                Body = { WrapperNamespace = ns }
            };

            for (int i = 0; i < parameters.Length; i++)
            {
                ParameterInfo parameterInfo = parameters[i];
                Type          parameterType = TypeLoader.GetParameterType(parameterInfo);
                if (!ComPlusTypeValidator.IsValidParameter(parameterType, parameterInfo, allowReferences))
                {
                    throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(System.ServiceModel.SR.GetString("InvalidWebServiceParameter", new object[] { parameterInfo.Name, parameterType.Name, methodName, contract.Name })));
                }
                MessagePartDescription item = this.CreateMessagePartDescription(parameterType, new System.ServiceModel.Description.XmlName(parameterInfo.Name), ns, i);
                description.Body.Parts.Add(item);
            }
            System.ServiceModel.Description.XmlName operationName = new System.ServiceModel.Description.XmlName(methodName);
            if (returnType == null)
            {
                description.Body.WrapperName = operationName.EncodedName;
                return(description);
            }
            description.Body.WrapperName = TypeLoader.GetBodyWrapperResponseName(operationName).EncodedName;
            if (!ComPlusTypeValidator.IsValidParameter(returnType, returnCustomAttributes, allowReferences))
            {
                throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(System.ServiceModel.SR.GetString("InvalidWebServiceReturnValue", new object[] { returnType.Name, methodName, contract.Name })));
            }
            MessagePartDescription description3 = this.CreateMessagePartDescription(returnType, returnValueName, ns, 0);

            description.Body.ReturnValue = description3;
            return(description);
        }
Ejemplo n.º 2
0
        MessageDescription CreateParameterMessageDescription(ContractDescription contract,
                                                             ParameterInfo[] parameters,
                                                             Type returnType,
                                                             ICustomAttributeProvider returnCustomAttributes,
                                                             XmlName returnValueName,
                                                             string methodName,
                                                             string ns,
                                                             string action,
                                                             MessageDirection direction,
                                                             bool allowReferences)
        {
            MessageDescription messageDescription = new MessageDescription(action, direction);

            messageDescription.Body.WrapperNamespace = ns;

            for (int index = 0; index < parameters.Length; index++)
            {
                ParameterInfo parameter     = parameters[index];
                Type          parameterType = TypeLoader.GetParameterType(parameter);

                if (!ComPlusTypeValidator.IsValidParameter(parameterType, parameter, allowReferences))
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(SR.GetString(SR.InvalidWebServiceParameter,
                                                                                                                    parameter.Name,
                                                                                                                    parameterType.Name,
                                                                                                                    methodName,
                                                                                                                    contract.Name)));
                }

                MessagePartDescription messagePart = CreateMessagePartDescription(parameterType,
                                                                                  new XmlName(parameter.Name),
                                                                                  ns,
                                                                                  index);
                messageDescription.Body.Parts.Add(messagePart);
            }

            XmlName xmlName = new XmlName(methodName);

            if (returnType == null)
            {
                messageDescription.Body.WrapperName = xmlName.EncodedName;
            }
            else
            {
                messageDescription.Body.WrapperName = TypeLoader.GetBodyWrapperResponseName(xmlName).EncodedName;

                if (!ComPlusTypeValidator.IsValidParameter(returnType, returnCustomAttributes, allowReferences))
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ListenerInitFailed(SR.GetString(SR.InvalidWebServiceReturnValue,
                                                                                                                    returnType.Name,
                                                                                                                    methodName,
                                                                                                                    contract.Name)));
                }

                MessagePartDescription messagePart = CreateMessagePartDescription(returnType,
                                                                                  returnValueName,
                                                                                  ns,
                                                                                  0);
                messageDescription.Body.ReturnValue = messagePart;
            }

            return(messageDescription);
        }