• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Channels.MessageVersion类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.ServiceModel.Channels.MessageVersion的典型用法代码示例。如果您正苦于以下问题:C# MessageVersion类的具体用法?C# MessageVersion怎么用?C# MessageVersion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MessageVersion类属于System.ServiceModel.Channels命名空间,在下文中一共展示了MessageVersion类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: PromoteException

        //Can only be called inside a service
        public static void PromoteException(Exception error,MessageVersion version,ref Message fault)
        {
            StackFrame frame = new StackFrame(1);

             Type serviceType = frame.GetMethod().ReflectedType;
             PromoteException(serviceType,error,version,ref fault);
        }
开发者ID:JMnITup,项目名称:SMEX,代码行数:8,代码来源:ErrorHandlerHelper.cs


示例2: ProvideFault

 //- @ProvideFault -//
 public virtual void ProvideFault(Exception error, MessageVersion version, ref Message fault)
 {
     fault.Properties[HttpResponseMessageProperty.Name] = new HttpResponseMessageProperty
                                                          {
                                                              StatusCode = HttpStatusCode.OK
                                                          };
 }
开发者ID:davidbetz,项目名称:Nalarium.ServiceModel,代码行数:8,代码来源:HttpStatusCode200ErrorHandler.cs


示例3: ErrorBehavior

 internal ErrorBehavior(ChannelDispatcher channelDispatcher)
 {
     this.handlers = EmptyArray<IErrorHandler>.ToArray(channelDispatcher.ErrorHandlers);
     this.debug = channelDispatcher.IncludeExceptionDetailInFaults;
     this.isOnServer = channelDispatcher.IsOnServer;
     this.messageVersion = channelDispatcher.MessageVersion;
 }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:7,代码来源:ErrorBehavior.cs


示例4: ProvideFault

      /// <summary>
      ///    Enables the creation of a custom System.ServiceModel.FaultException{TDetail}
      ///    that is returned from an exception in the course of a service method.
      /// </summary>
      /// <param name="error">The System.Exception object thrown in the course of the service operation.</param>
      /// <param name="version">The SOAP version of the message.</param>
      /// <param name="fault">
      ///    The System.ServiceModel.Channels.Message object that is returned to the client, or service in
      ///    duplex case
      /// </param>
      public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
      {
         if (error is FaultException<ApplicationServiceError>)
         {
            var messageFault = ((FaultException<ApplicationServiceError>) error).CreateMessageFault();

            //propagate FaultException
            fault = Message.CreateMessage(
               version,
               messageFault,
               ((FaultException<ApplicationServiceError>) error).Action);
         }
         else
         {
            //create service error
            var defaultError = new ApplicationServiceError()
            {
               ErrorMessage = Messages.message_DefaultErrorMessage
            };

            //Create fault exception and message fault
            var defaultFaultException = new FaultException<ApplicationServiceError>(defaultError);
            var defaultMessageFault = defaultFaultException.CreateMessageFault();

            //propagate FaultException
            fault = Message.CreateMessage(version, defaultMessageFault, defaultFaultException.Action);
         }
      }
开发者ID:MyLobin,项目名称:NLayerAppV2,代码行数:38,代码来源:ApplicationErrorHandler.cs


示例5: ProvideFault

        public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
        {
            FaultException faultException;
            var logger = LogManager.GetCurrentClassLogger();

            if (error != null && error is ObjectValidationException)
            {
                faultException = new FaultException<ValidationFault>(new ValidationFault(((ObjectValidationException)error).ValidationErrors.Select(item =>
                    new ValidationError
                    {
                        ErrorMessage = item.ErrorMessage,
                        ObjectName = item.ObjectName,
                        PropertyName = item.PropertyName
                    })), new FaultReason("Validation error"));

                logger.Error(error, "Validation error in GlobalError filter");
            }
            else
            {
                faultException = new FaultException<InternalServiceFault>(new InternalServiceFault(error,
                string.Format("Exception caught at GlobalErrorHandler{0}Method: {1}{2}Message:{3}",
                             Environment.NewLine, error.TargetSite.Name, Environment.NewLine, error.Message)));

                logger.Error(error, "Generic internal error in GlobalError filter");
            }
            // Shield the unknown exception
            //FaultException faultException = new FaultException<SimpleErrorFault>(new SimpleErrorFault(), new FaultReason("Server error encountered. All details have been logged."));
            //new FaultException("Server error encountered. All details have been logged.");
            MessageFault messageFault = faultException.CreateMessageFault();

            fault = Message.CreateMessage(version, messageFault, faultException.Action);
        }
开发者ID:GrgDmr,项目名称:CDAManager,代码行数:32,代码来源:GlobalErrorHandler.cs


示例6: ProvideFault

 internal Message ProvideFault(MessageVersion messageVersion)
 {
     WSAddressing10ProblemHeaderQNameFault fault = new WSAddressing10ProblemHeaderQNameFault(this);
     Message message = Message.CreateMessage(messageVersion, fault, messageVersion.Addressing.FaultAction);
     fault.AddHeaders(message.Headers);
     return message;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:ActionMismatchAddressingException.cs


示例7: SerializeReply

        public Message SerializeReply(MessageVersion messageVersion, object[] parameters, object result)
        {
            WebOperationContext currentContext = WebOperationContext.Current;
            OutgoingWebResponseContext outgoingResponse = null;

            if (currentContext != null)
            {
                outgoingResponse = currentContext.OutgoingResponse;
            }
            
            WebMessageFormat format = this.defaultFormat;
            if (outgoingResponse != null)
            {
                WebMessageFormat? nullableFormat = outgoingResponse.Format;
                if (nullableFormat.HasValue)
                {
                    format = nullableFormat.Value;
                }
            }

            if (!this.formatters.ContainsKey(format))
            {
                string operationName = "<null>";

                if (OperationContext.Current != null)
                {
                    MessageProperties messageProperties = OperationContext.Current.IncomingMessageProperties;
                    if (messageProperties.ContainsKey(WebHttpDispatchOperationSelector.HttpOperationNamePropertyName))
                    {
                        operationName = messageProperties[WebHttpDispatchOperationSelector.HttpOperationNamePropertyName] as string;
                    }
                }
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR2.GetString(SR2.OperationDoesNotSupportFormat, operationName, format.ToString())));
            }

            if (outgoingResponse != null && string.IsNullOrEmpty(outgoingResponse.ContentType))
            {
                string automatedSelectionContentType = outgoingResponse.AutomatedFormatSelectionContentType;
                if (!string.IsNullOrEmpty(automatedSelectionContentType))
                {
                    // Don't set the content-type if it is default xml for backwards compatiabilty
                    if (!string.Equals(automatedSelectionContentType, defaultContentTypes[WebMessageFormat.Xml], StringComparison.OrdinalIgnoreCase))
                    {
                        outgoingResponse.ContentType = automatedSelectionContentType;
                    }
                }
                else
                {
                    // Don't set the content-type if it is default xml for backwards compatiabilty
                    if (format != WebMessageFormat.Xml)
                    {
                        outgoingResponse.ContentType = defaultContentTypes[format];
                    }
                }
            }

            Message message = this.formatters[format].SerializeReply(messageVersion, parameters, result);

            return message;
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:60,代码来源:MultiplexingDispatchMessageFormatter.cs


示例8: OnImportPolicy

		protected virtual void OnImportPolicy (XmlElement assertion,
			MessageVersion messageVersion,
			MetadataImporter exporter,
			PolicyConversionContext context)
		{
			throw new NotImplementedException ();
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:7,代码来源:MessageEncodingBindingElement.cs


示例9: CustomTextMessageEncoderFactory

 internal CustomTextMessageEncoderFactory(string mediaType, string charSet, MessageVersion version)
 {
     _version = version;
     _mediaType = mediaType;
     _charSet = charSet;
     _encoder = new CustomTextMessageEncoder(this);
 }
开发者ID:weshaggard,项目名称:wcf,代码行数:7,代码来源:CustomTextMessageEncoderFactory.cs


示例10: SerializeReply

 public Message SerializeReply(MessageVersion messageVersion, object[] parameters, object result)
 {
     JObject json = new JObject();
     json[JsonRpcConstants.ErrorKey] = null;
     json[JsonRpcConstants.ResultKey] = JToken.FromObject(result);
     return JsonRpcHelpers.SerializeMessage(json, null);
 }
开发者ID:GusLab,项目名称:WCFSamples,代码行数:7,代码来源:JsonRpcMessageFormatter.cs


示例11: ProvideFault

        public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
        {
            Contract.Requires<NullReferenceException>(error != null);

            FaultCode code = FaultCode.CreateSenderFaultCode(error.GetType().Name, FaultNs);
            fault = Message.CreateMessage(version, code, error.Message, null);

        if (this.Context != null)
        {
            var se = error as ServiceException;
            if (se != null)
            {
                Context.OutgoingResponse.StatusCode = ((ServiceException)error).StatusCode;
            }

            var sb = new StringBuilder();

            for (int i = 0; i < error.Message.Length; i++)
            {
                var ch = (char)('\x00ff' & error.Message[i]);
                if (((ch <= '\x001f') && (ch != '\t')) || (ch == '\x007f'))
                {
                    // Specified value has invalid Control characters.
                    // See HttpListenerResponse.StatusDescription implementation.
                }
                else
                {
                    sb.Append(ch);
                }
            }

            Context.OutgoingResponse.StatusDescription = sb.ToString();
            Context.OutgoingResponse.SuppressEntityBody = false;
            }
        }
开发者ID:amido,项目名称:Amido.PreProcessor,代码行数:35,代码来源:ErrorHandler.cs


示例12: ArgumentNullException

        /// <summary>
        /// Serializes a reply message from a specified message version, array of parameters, and a return value.
        /// </summary>
        /// <param name="messageVersion">The SOAP message version.</param>
        /// <param name="parameters">The out parameters.</param>
        /// <param name="result">The return value.</param>
        /// <returns>he serialized reply message.</returns>
        Message IDispatchMessageFormatter.SerializeReply(
            MessageVersion messageVersion,
            object[] parameters,
            object result)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }

            if (messageVersion != MessageVersion.None)
            {
                throw new NotSupportedException(
                    string.Format(
                        CultureInfo.CurrentCulture,
                        SR.HttpMessageFormatterMessageVersion,
                        this.GetType()));
            }

            HttpResponseMessage response = this.GetDefaultResponse();
            if (response == null)
            {
                 throw new InvalidOperationException(
                    string.Format(
                        CultureInfo.CurrentCulture,
                        SR.HttpMessageFormatterNullResponse,
                        this.GetType()));
            }

            this.SerializeReply(parameters, result, response);

            return response.ToMessage();
        }
开发者ID:AlexZeitler,项目名称:WcfHttpMvcFormsAuth,代码行数:40,代码来源:HttpMessageFormatter.cs


示例13: CreateMessage

 public Message CreateMessage(MessageVersion messageVersion, ReliableMessagingVersion reliableMessagingVersion)
 {
     this.SetReliableMessagingVersion(reliableMessagingVersion);
     string faultActionString = WsrmIndex.GetFaultActionString(messageVersion.Addressing, reliableMessagingVersion);
     if (messageVersion.Envelope == EnvelopeVersion.Soap11)
     {
         this.code = this.Get11Code(this.code, this.subcode);
     }
     else
     {
         if (messageVersion.Envelope != EnvelopeVersion.Soap12)
         {
             throw Fx.AssertAndThrow("Unsupported MessageVersion.");
         }
         if (this.code.SubCode == null)
         {
             FaultCode subCode = new FaultCode(this.subcode, WsrmIndex.GetNamespaceString(reliableMessagingVersion));
             this.code = new FaultCode(this.code.Name, this.code.Namespace, subCode);
         }
         this.hasDetail = this.Get12HasDetail();
     }
     Message message = Message.CreateMessage(messageVersion, this, faultActionString);
     this.OnFaultMessageCreated(messageVersion, message);
     return message;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:25,代码来源:WsrmFault.cs


示例14: BufferedHeader

 public BufferedHeader(MessageVersion version, XmlBuffer buffer, XmlDictionaryReader reader, XmlAttributeHolder[] envelopeAttributes, XmlAttributeHolder[] headerAttributes)
 {
     this.streamed = true;
     this.buffer = buffer;
     this.version = version;
     MessageHeader.GetHeaderAttributes(reader, version, out this.actor, out this.mustUnderstand, out this.relay, out this.isRefParam);
     this.name = reader.LocalName;
     this.ns = reader.NamespaceURI;
     this.bufferIndex = buffer.SectionCount;
     XmlDictionaryWriter writer = buffer.OpenSection(reader.Quotas);
     writer.WriteStartElement("Envelope");
     if (envelopeAttributes != null)
     {
         XmlAttributeHolder.WriteAttributes(envelopeAttributes, writer);
     }
     writer.WriteStartElement("Header");
     if (headerAttributes != null)
     {
         XmlAttributeHolder.WriteAttributes(headerAttributes, writer);
     }
     writer.WriteNode(reader, false);
     writer.WriteEndElement();
     writer.WriteEndElement();
     buffer.CloseSection();
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:25,代码来源:BufferedHeader.cs


示例15: ProvideFault

            public void ProvideFault(Exception exception, MessageVersion version, ref Message fault)
            {
                if (exception.GetType() == typeof(HttpException))
                {
                    var httpException = (HttpException)exception;

                    var inResponse = WebOperationContext.Current.IncomingRequest;

                    var webGetAttribute = GetCurrentAttribute(inResponse);
                    
                    if(webGetAttribute == null)
                    {
                        throw new RestException();    
                    }

                    var currentResponseFormat = webGetAttribute.ResponseFormat;

                    var restErrorMessage = new RestErrorMessage(httpException.Data, httpException.GetHttpCode(), httpException.ErrorCode);
                    fault = CreateMessage(restErrorMessage, version, currentResponseFormat);
                    fault.Properties.Add(WebBodyFormatMessageProperty.Name, GetBodyFormat(currentResponseFormat));

                    var outResponse = WebOperationContext.Current.OutgoingResponse;
                    outResponse.StatusCode = (HttpStatusCode)httpException.GetHttpCode();
                    outResponse.ContentType = string.Format("application/{0}", currentResponseFormat);
                }
                else
                {
                    throw new RestException();
                }
            }
开发者ID:apavlo11356,项目名称:adamdotcom-services,代码行数:30,代码来源:WebHttpWithExceptions.cs


示例16: ProvideFault

        public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
        {
            var newEx = new FaultException(string.Format("服务端错误 {0}", error.TargetSite.Name));
            MessageFault msgFault = newEx.CreateMessageFault();

            fault = Message.CreateMessage(version, msgFault, newEx.Action);
        }
开发者ID:dennyli,项目名称:HandySolution,代码行数:7,代码来源:LighterErrorHandler.cs


示例17: ProvideFault

        /// <summary>
        /// Enables the creation of a custom <see cref="System.ServiceModel.FaultException"/>
        /// that is returned from an exception in the course of a service method.
        /// </summary>
        /// <param name="error"></param>
        /// <param name="version"></param>
        /// <param name="faultMessage"></param>
        public void ProvideFault(Exception error, MessageVersion version, ref Message faultMessage)
        {
            // Gets a serializable Fault object fromn error.
            Fault fault = Fault.GetFault(error);

            // Now we make the message by serializing the Fault to JSON.
            faultMessage = Message.CreateMessage(version, null, fault,
              new DataContractJsonSerializer(fault.GetType()));

            // Gotta set HTTP status codes.
            HttpResponseMessageProperty prop = new HttpResponseMessageProperty()
            {
                StatusCode = HttpStatusCode.InternalServerError, // 500
                StatusDescription = "An internal server error occurred." // Could use elaboration.
            };

            // Make sure to set the content type. Important for avoiding
            // certain kinds of encoding-specific XSS attacks.
            prop.Headers[HttpResponseHeader.ContentType] = "application/json; charset=utf-8";

            // Set a few other properties of the Message.
            faultMessage.Properties.Add(HttpResponseMessageProperty.Name, prop);
            faultMessage.Properties.Add(WebBodyFormatMessageProperty.Name,
                new WebBodyFormatMessageProperty(WebContentFormat.Json));
        }
开发者ID:ZaneKaminski,项目名称:wcf-raw-json,代码行数:32,代码来源:JsonErrorHandler.cs


示例18: ReadMessage

 public static CreateSequenceInfo ReadMessage(MessageVersion messageVersion, ReliableMessagingVersion reliableMessagingVersion, ISecureConversationSession securitySession, Message message, MessageHeaders headers)
 {
     CreateSequenceInfo info;
     if (message.IsEmpty)
     {
         string reason = System.ServiceModel.SR.GetString("NonEmptyWsrmMessageIsEmpty", new object[] { WsrmIndex.GetCreateSequenceActionString(reliableMessagingVersion) });
         Message faultReply = WsrmUtilities.CreateCSRefusedProtocolFault(messageVersion, reliableMessagingVersion, reason);
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(WsrmMessageInfo.CreateInternalFaultException(faultReply, reason, new ProtocolException(reason)));
     }
     using (XmlDictionaryReader reader = message.GetReaderAtBodyContents())
     {
         info = CreateSequence.Create(messageVersion, reliableMessagingVersion, securitySession, reader);
         message.ReadFromBodyContentsToEnd(reader);
     }
     info.SetMessageId(messageVersion, headers);
     info.SetReplyTo(messageVersion, headers);
     if (info.AcksTo.Uri != info.ReplyTo.Uri)
     {
         string str2 = System.ServiceModel.SR.GetString("CSRefusedAcksToMustEqualReplyTo");
         Message message3 = WsrmUtilities.CreateCSRefusedProtocolFault(messageVersion, reliableMessagingVersion, str2);
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(WsrmMessageInfo.CreateInternalFaultException(message3, str2, new ProtocolException(str2)));
     }
     info.to = message.Headers.To;
     if ((info.to == null) && (messageVersion.Addressing == AddressingVersion.WSAddressing10))
     {
         info.to = messageVersion.Addressing.AnonymousUri;
     }
     return info;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:29,代码来源:CreateSequenceInfo.cs


示例19: IssuedTokensHeader

 public IssuedTokensHeader(XmlReader xmlReader, MessageVersion version, SecurityStandardsManager standardsManager)
     : base()
 {
     if (xmlReader == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("xmlReader");
     }
     if (standardsManager == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("standardsManager"));
     }
     this.standardsManager = standardsManager;
     XmlDictionaryReader reader = XmlDictionaryReader.CreateDictionaryReader(xmlReader);
     MessageHeader.GetHeaderAttributes(reader, version, out this.actor, out this.mustUnderstand, out this.relay, out this.isRefParam);
     reader.ReadStartElement(this.Name, this.Namespace);
     Collection<RequestSecurityTokenResponse> coll = new Collection<RequestSecurityTokenResponse>();
     if (this.standardsManager.TrustDriver.IsAtRequestSecurityTokenResponseCollection(reader))
     {
         RequestSecurityTokenResponseCollection rstrColl = this.standardsManager.TrustDriver.CreateRequestSecurityTokenResponseCollection(reader);
         foreach (RequestSecurityTokenResponse rstr in rstrColl.RstrCollection)
         {
             coll.Add(rstr);
         }
     }
     else
     {
         RequestSecurityTokenResponse rstr = this.standardsManager.TrustDriver.CreateRequestSecurityTokenResponse(reader);
         coll.Add(rstr);
     }
     this.tokenIssuances = new ReadOnlyCollection<RequestSecurityTokenResponse>(coll);
     reader.ReadEndElement();
 }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:32,代码来源:IssuedTokensHeader.cs


示例20: SelectChannelFactory

 protected override IChannelFactory<IRequestReplyService> SelectChannelFactory(out MessageVersion messageVersion)
 {
     base.interoperating = false;
     EndpointIdentity identity = base.to.Identity;
     if (identity != null)
     {
         string claimType = identity.IdentityClaim.ClaimType;
         if ((claimType != ClaimTypes.Spn) && (claimType != ClaimTypes.Upn))
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CreateChannelFailureException(Microsoft.Transactions.SR.GetString("InvalidTrustIdentityType", new object[] { claimType })));
         }
     }
     string scheme = base.to.Uri.Scheme;
     if (string.Compare(scheme, Uri.UriSchemeNetPipe, StringComparison.OrdinalIgnoreCase) == 0)
     {
         messageVersion = base.coordinationService.NamedPipeActivationBinding.MessageVersion;
         return base.coordinationService.NamedPipeActivationChannelFactory;
     }
     if (!base.coordinationService.Config.RemoteClientsEnabled || (string.Compare(scheme, Uri.UriSchemeHttps, StringComparison.OrdinalIgnoreCase) != 0))
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new CreateChannelFailureException(Microsoft.Transactions.SR.GetString("InvalidSchemeWithTrustIdentity", new object[] { scheme })));
     }
     messageVersion = base.coordinationService.WindowsActivationBinding.MessageVersion;
     return base.coordinationService.WindowsActivationChannelFactory;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:25,代码来源:WindowsActivationProxy.cs



注:本文中的System.ServiceModel.Channels.MessageVersion类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Channels.RequestContext类代码示例发布时间:2022-05-26
下一篇:
C# Channels.Message类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap