コード例 #1
0
        public void ApplyClientBehavior(OperationDescription description, System.ServiceModel.Dispatcher.ClientOperation proxy)
        {
            description.Behaviors.Clear();
            IOperationBehavior innerBehavior = new WCFCustomDataContractSerializerOperationBehavior(description, maxItemsInObjectGraph);

            innerBehavior.ApplyClientBehavior(description, proxy);
        }
コード例 #2
0
		public void ApplyClientBehavior(OperationDescription description, System.ServiceModel.Dispatcher.ClientOperation proxy)
		{
			var dataContractSerializerOperationBehavior =
				description.Behaviors.Find<DataContractSerializerOperationBehavior>();
			dataContractSerializerOperationBehavior.DataContractResolver =
				new ProxyDataContractResolver();
		}
コード例 #3
0
        public void ApplyClientBehavior(OperationDescription description,
                                        System.ServiceModel.Dispatcher.ClientOperation proxy)
        {
            IOperationBehavior innerBehavior =
                new ReferencePreservingDataContractSerializerOperationBehavior(description);

            innerBehavior.ApplyClientBehavior(description, proxy);
        }
コード例 #4
0
        Message CreateRequest(System.ServiceModel.Dispatcher.ClientOperation op, object[] parameters, System.ServiceModel.OperationContext context)
        {
            MessageVersion version = message_version;

            if (version == null)
            {
                version = MessageVersion.Default;
            }
            Message msg;

            if (op.SerializeRequest)
            {
                msg = op.Formatter.SerializeRequest(version, parameters);
            }
            else
            {
                if (parameters.Length != 1)
                {
                    throw new ArgumentException(String.Format("Argument parameters does not match the expected input. It should contain only a Message, but has {0} parameters", parameters.Length));
                }
                if (!(parameters[0] is Message))
                {
                    throw new ArgumentException(String.Format("Argument should be only a Message, but has {0}", parameters[0] != null ? parameters[0].GetType().FullName : "null"));
                }
                msg = (Message)parameters[0];
            }
            context = context ?? System.ServiceModel.OperationContext.Current;
            if (context != null)
            {
                foreach (var mh in context.OutgoingMessageHeaders)
                {
                    int x = msg.Headers.FindHeader(mh.Name, mh.Namespace, mh.Actor);
                    if (x >= 0)
                    {
                        msg.Headers.RemoveAt(x);
                    }
                    msg.Headers.Add((MessageHeader)mh);
                }
                msg.Properties.CopyProperties(context.OutgoingMessageProperties);
            }
            msg.Properties.AllowOutputBatching = AllowOutputBatching;
            if (msg.Version.Addressing.Equals(AddressingVersion.WSAddressing10))
            {
                if (msg.Headers.MessageId == null)
                {
                    msg.Headers.MessageId = new System.Xml.UniqueId();
                }
                if (msg.Headers.ReplyTo == null)
                {
                    msg.Headers.ReplyTo = new System.ServiceModel.EndpointAddress(Constants.WsaAnonymousUri);
                }
                if (msg.Headers.To == null && RemoteAddress != null)
                {
                    msg.Headers.To = RemoteAddress.Uri;
                }
            }
            return(msg);
        }
コード例 #5
0
 public void ApplyClientBehavior(OperationDescription operationDescription, System.ServiceModel.Dispatcher.ClientOperation clientOperation)
 {
     clientOperation.Formatter        = new XmlRpcOperationFormatter(operationDescription);
     clientOperation.SerializeRequest = clientOperation.DeserializeReply = true;
 }
コード例 #6
0
 public void ApplyClientBehavior(OperationDescription operationDescription, System.ServiceModel.Dispatcher.ClientOperation clientOperation)
 {
     clientOperation.ParameterInspectors.Add(
         new ZipCodeInspector(index));
 }
コード例 #7
0
 public void ApplyClientBehavior(OperationDescription description, System.ServiceModel.Dispatcher.ClientOperation proxy)
 {
     //nothing to do
 }
コード例 #8
0
 public void ApplyClientBehavior(OperationDescription operationDescription, System.ServiceModel.Dispatcher.ClientOperation clientOperation)
 {
     clientOperation.ParameterInspectors.Add(new ValidadorNotacionInspector());
 }
コード例 #9
0
 public void ApplyClientBehavior(System.ServiceModel.Description.OperationDescription operationDescription, System.ServiceModel.Dispatcher.ClientOperation clientOperation)
 {
     ApplyDataContractSurrogate(operationDescription);
 }
 void System.ServiceModel.Description.IOperationBehavior.ApplyClientBehavior(OperationDescription description, System.ServiceModel.Dispatcher.ClientOperation proxy)
 {
 }
コード例 #11
0
        object Request(OperationDescription od, bool isAsync, ref object[] parameters, System.ServiceModel.OperationContext context)
        {
            System.ServiceModel.Dispatcher.ClientOperation op = runtime.Operations[od.Name];
            object[] inspections = new object[runtime.MessageInspectors.Count];
            Message  req         = CreateRequest(op, parameters, context);

            for (int i = 0; i < inspections.Length; i++)
            {
                inspections[i] = runtime.MessageInspectors[i].BeforeSendRequest(ref req, this);
            }
            Message res = Request(req, OperationTimeout);

            if (res.IsFault)
            {
                var          resb  = res.CreateBufferedCopy(runtime.MaxFaultSize);
                MessageFault fault = MessageFault.CreateFault(resb.CreateMessage(), runtime.MaxFaultSize);
                var          conv  = OperationChannel.GetProperty <FaultConverter>() ?? FaultConverter.GetDefaultFaultConverter(res.Version);
                Exception    ex;
                if (!conv.TryCreateException(resb.CreateMessage(), fault, out ex))
                {
                    if (fault.HasDetail)
                    {
                        Type detailType = typeof(System.ServiceModel.ExceptionDetail);
                        var  freader    = fault.GetReaderAtDetailContents();
                        System.Runtime.Serialization.DataContractSerializer ds = null;
                        foreach (var fci in op.FaultContractInfos)
                        {
                            if (res.Headers.Action == fci.Action || GetSerializer(fci).IsStartObject(freader))
                            {
                                detailType = fci.Detail;
                                ds         = GetSerializer(fci);
                                break;
                            }
                        }
                        if (ds == null)
                        {
                            ds = new System.Runtime.Serialization.DataContractSerializer(detailType);
                        }
                        var detail = ds.ReadObject(freader);
                        ex = (Exception)Activator.CreateInstance(typeof(System.ServiceModel.FaultException <>).MakeGenericType(detailType), new object[] {
                            detail,
                            fault.Reason,
                            fault.Code,
                            res.Headers.Action
                        });
                    }
                    if (ex == null)
                    {
                        ex = new System.ServiceModel.FaultException(fault);
                    }
                }
                throw ex;
            }
            for (int i = 0; i < inspections.Length; i++)
            {
                runtime.MessageInspectors[i].AfterReceiveReply(ref res, inspections[i]);
            }
            if (!op.DeserializeReply)
            {
                return(res);
            }
            if (isAsync && od.EndMethod != null)
            {
                var endParams = od.EndMethod.GetParameters();
                parameters = new object[endParams.Length - 1];
            }
            return(op.Formatter.DeserializeReply(res, parameters));
        }
コード例 #12
0
 void Output(OperationDescription od, object[] parameters, System.ServiceModel.OperationContext context)
 {
     System.ServiceModel.Dispatcher.ClientOperation op = runtime.Operations[od.Name];
     Send(CreateRequest(op, parameters, context), OperationTimeout);
 }
コード例 #13
0
        public void ApplyClientBehavior(OperationDescription description, System.ServiceModel.Dispatcher.ClientOperation proxy)
        {
            IOperationBehavior innerBehavior = new KnownTypesDataContractSerializerOperationBehavior(description, BaseType);

            innerBehavior.ApplyClientBehavior(description, proxy);
        }
コード例 #14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="description"></param>
        /// <param name="proxy"></param>
        public void ApplyClientBehavior(OperationDescription description, System.ServiceModel.Dispatcher.ClientOperation proxy)
        {
            var behavior = description.Behaviors.Find <DataContractSerializerOperationBehavior>();

            behavior.DataContractResolver = Activator.CreateInstance(_dataContractResolverType) as DataContractResolver;
        }
コード例 #15
0
 public void ApplyClientBehavior(OperationDescription description, System.ServiceModel.Dispatcher.ClientOperation proxy)
 {
     SetResolver(description);
 }
コード例 #16
0
 public void ApplyClientBehavior(OperationDescription description, System.ServiceModel.Dispatcher.ClientOperation proxy)
 {
     ApplyDataContractSurrogate(description);
 }
コード例 #17
0
 public void ApplyClientBehavior(OperationDescription description,
                                 System.ServiceModel.Dispatcher.ClientOperation proxy)
 {
     ReplaceDataContractSerializerOperationBehavior(description);
 }
コード例 #18
0
 public void ApplyClientBehavior(OperationDescription operationDescription, System.ServiceModel.Dispatcher.ClientOperation clientOperation)
 {
     clientOperation.SerializeRequest = true;
     clientOperation.DeserializeReply = true;
     clientOperation.Formatter        = new Base64BodyFormatter(clientOperation.Formatter);
 }
コード例 #19
0
 void IOperationBehavior.ApplyClientBehavior(OperationDescription operationDescription, System.ServiceModel.Dispatcher.ClientOperation clientOperation)
 {
 }
コード例 #20
0
 public void ApplyClientBehavior(System.ServiceModel.Description.OperationDescription operationDescription, System.ServiceModel.Dispatcher.ClientOperation clientOperation)
 {
     throw new NotImplementedException();
 }
コード例 #21
0
 void IOperationBehavior.ApplyClientBehavior(OperationDescription operationDescription, System.ServiceModel.Dispatcher.ClientOperation clientOperation)
 {
     CyclicReferencesAwareContractBehavior.ReplaceDataContractSerializerOperationBehavior(operationDescription, On);
 }
コード例 #22
0
 public void ApplyClientBehavior(OperationDescription operationDescription, System.ServiceModel.Dispatcher.ClientOperation clientOperation)
 {
     return;
 }