public void ApplyClientBehavior(OperationDescription description, System.ServiceModel.Dispatcher.ClientOperation proxy)
        {
            description.Behaviors.Clear();
            IOperationBehavior innerBehavior = new WCFCustomDataContractSerializerOperationBehavior(description, maxItemsInObjectGraph);

            innerBehavior.ApplyClientBehavior(description, proxy);
        }
Ejemplo n.º 2
0
		public void ApplyClientBehavior(OperationDescription description, System.ServiceModel.Dispatcher.ClientOperation proxy)
		{
			var dataContractSerializerOperationBehavior =
				description.Behaviors.Find<DataContractSerializerOperationBehavior>();
			dataContractSerializerOperationBehavior.DataContractResolver =
				new ProxyDataContractResolver();
		}
        public void ApplyClientBehavior(OperationDescription description,
                                        System.ServiceModel.Dispatcher.ClientOperation proxy)
        {
            IOperationBehavior innerBehavior =
                new ReferencePreservingDataContractSerializerOperationBehavior(description);

            innerBehavior.ApplyClientBehavior(description, proxy);
        }
Ejemplo n.º 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);
        }
 public void ApplyClientBehavior(OperationDescription operationDescription, System.ServiceModel.Dispatcher.ClientOperation clientOperation)
 {
     clientOperation.Formatter        = new XmlRpcOperationFormatter(operationDescription);
     clientOperation.SerializeRequest = clientOperation.DeserializeReply = true;
 }
 public void ApplyClientBehavior(OperationDescription operationDescription, System.ServiceModel.Dispatcher.ClientOperation clientOperation)
 {
     clientOperation.ParameterInspectors.Add(
         new ZipCodeInspector(index));
 }
Ejemplo n.º 7
0
 public void ApplyClientBehavior(OperationDescription description, System.ServiceModel.Dispatcher.ClientOperation proxy)
 {
     //nothing to do
 }
Ejemplo n.º 8
0
 public void ApplyClientBehavior(OperationDescription operationDescription, System.ServiceModel.Dispatcher.ClientOperation clientOperation)
 {
     clientOperation.ParameterInspectors.Add(new ValidadorNotacionInspector());
 }
Ejemplo n.º 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)
 {
 }
Ejemplo n.º 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));
        }
Ejemplo n.º 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);
 }
Ejemplo n.º 13
0
        public void ApplyClientBehavior(OperationDescription description, System.ServiceModel.Dispatcher.ClientOperation proxy)
        {
            IOperationBehavior innerBehavior = new KnownTypesDataContractSerializerOperationBehavior(description, BaseType);

            innerBehavior.ApplyClientBehavior(description, proxy);
        }
        /// <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;
        }
Ejemplo n.º 15
0
 public void ApplyClientBehavior(OperationDescription description, System.ServiceModel.Dispatcher.ClientOperation proxy)
 {
     SetResolver(description);
 }
Ejemplo n.º 16
0
 public void ApplyClientBehavior(OperationDescription description, System.ServiceModel.Dispatcher.ClientOperation proxy)
 {
     ApplyDataContractSurrogate(description);
 }
 public void ApplyClientBehavior(OperationDescription description,
                                 System.ServiceModel.Dispatcher.ClientOperation proxy)
 {
     ReplaceDataContractSerializerOperationBehavior(description);
 }
Ejemplo n.º 18
0
 public void ApplyClientBehavior(OperationDescription operationDescription, System.ServiceModel.Dispatcher.ClientOperation clientOperation)
 {
     clientOperation.SerializeRequest = true;
     clientOperation.DeserializeReply = true;
     clientOperation.Formatter        = new Base64BodyFormatter(clientOperation.Formatter);
 }
Ejemplo n.º 19
0
 void IOperationBehavior.ApplyClientBehavior(OperationDescription operationDescription, System.ServiceModel.Dispatcher.ClientOperation clientOperation)
 {
 }
Ejemplo n.º 20
0
 public void ApplyClientBehavior(System.ServiceModel.Description.OperationDescription operationDescription, System.ServiceModel.Dispatcher.ClientOperation clientOperation)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 21
0
 void IOperationBehavior.ApplyClientBehavior(OperationDescription operationDescription, System.ServiceModel.Dispatcher.ClientOperation clientOperation)
 {
     CyclicReferencesAwareContractBehavior.ReplaceDataContractSerializerOperationBehavior(operationDescription, On);
 }
Ejemplo n.º 22
0
 public void ApplyClientBehavior(OperationDescription operationDescription, System.ServiceModel.Dispatcher.ClientOperation clientOperation)
 {
     return;
 }