Exemple #1
0
        private static void PreparedArguments(OperationRequest request)
        {
            if (request == null)
                throw new ArgumentNullException("request");

            if (string.IsNullOrWhiteSpace(request.TargetOperationId))
                throw new ArgumentException("The 'TargetOperation' property for operation request is required.");

            if (string.IsNullOrWhiteSpace(request.TargetMethod))
                throw new ArgumentException("The 'TargetMethod' property for opertation request is required.");
        }
Exemple #2
0
        public void TestMethod1()
        {
            UserDo userInfo = new UserDo()
            {
                Name = "diana.wu",
                Password = "******",
                Email = "*****@*****.**",
                Mobile = "15913135168",
                EffectiveDate = DateTime.Now,
                ExpiryDate = DateTime.Now.AddYears(5)
            };

            OperationRequest request = new OperationRequest()
            {
                TargetOperationId = "userOperation",
                TargetMethod = OperationMethod.Create,
                OperationArgs = SerializerUtils.SerializeBinary(new object[] { userInfo })
            };

            response = ClientProxy.InvokeOperation(request);

            System.Diagnostics.Debug.Assert(response.Result.Status == OperationResultType.Ok);
        }
Exemple #3
0
        public static OperationResponse InvokeOperation(OperationRequest request)
        {
            request.Url = dispatcher.Url;

            OperationResponse response = new OperationResponse()
            {
                Result = new OperationResult()
                {
                    Message = "Client error",
                    Type = OperationResultType.Error
                }
            };
            PreparedArguments(request);

            if (request.OperationArgs is Object[])
            {
                byte[] serializedArguments = SerializerUtils.SerializeBinary((Object[])request.OperationArgs);
                request.OperationArgs = serializedArguments;
            }

            try
            {
                response = dispatcher.Post(request);
                if (response.Result.Type == OperationResultType.Ok)
                {
                    byte[] uncompressedResult = SevenZipUtils.ExtractBytes((byte[])response.Result.Value);
                    object[] results = SerializerUtils.DeserializeBinary(uncompressedResult);
                    response.Result.Value = results[0];
                }
            }
            catch(Exception ex)
            {
                response.Result.Message = ex.Message;
            }

            return response;
        }
Exemple #4
0
 /// <remarks/>
 public System.IAsyncResult BeginPost(OperationRequest request, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("Post", new object[] {
                 request}, callback, asyncState);
 }
Exemple #5
0
 /// <remarks/>
 public void PostAsync(OperationRequest request, object userState)
 {
     if ((this.PostOperationCompleted == null)) {
         this.PostOperationCompleted = new System.Threading.SendOrPostCallback(this.OnPostOperationCompleted);
     }
     this.InvokeAsync("Post", new object[] {
                 request}, this.PostOperationCompleted, userState);
 }
Exemple #6
0
 /// <remarks/>
 public void PostAsync(OperationRequest request)
 {
     this.PostAsync(request, null);
 }
Exemple #7
0
 public OperationResponse Post(OperationRequest request)
 {
     object[] results = this.Invoke("Post", new object[] {
                 request});
     return ((OperationResponse)(results[0]));
 }