示例#1
0
        public object BeforeSendRequest(ref Message request, System.ServiceModel.IClientChannel channel)
        {
            if (_userName != null)
            {
                var nameHeader = MessageHeader.CreateHeader("UserName", "Authentication", _userName);
                if (request.Headers.FindHeader("UserName", "Authentication") <= 0)
                {
                    request.Headers.Add(nameHeader);
                }
            }
            if (_userPassword != null)
            {
                var passwordHeader = MessageHeader.CreateHeader("UserPassword", "Authentication", _userPassword);
                if (request.Headers.FindHeader("UserPassword", "Authentication") <= 0)
                {
                    request.Headers.Add(passwordHeader);
                }
            }
            if (_customerId != null)
            {
                var idHeader = MessageHeader.CreateHeader("CustomerId", "Authentication", _customerId);
                if (request.Headers.FindHeader("CustomerId", "Authentication") <= 0)
                {
                    request.Headers.Add(idHeader);
                }
            }
            var clientApplicationTypeHeader = MessageHeader.CreateHeader("ClientApplicationType", "Authentication", 3);

            if (request.Headers.FindHeader("ClientApplicationType", "Authentication") <= 0)
            {
                request.Headers.Add(clientApplicationTypeHeader);
            }

            return(null);
        }
        public object BeforeSendRequest(ref Message request, IClientChannel channel)
        {
            var header = MessageHeader.CreateHeader("AuthenticationToken", "urn:Curse.FriendsService:v1", Token);

            request.Headers.Add(header);
            return(null);
        }
示例#3
0
        static void Main(string[] args)
        {
            try
            {
                var aqAquisitionServiceClient = new AQAcquisitionServiceClient("BasicHttpBinding_IAQAcquisitionService", "http://sooke/AQUARIUS/AqAcquisitionService.svc/Basic");
                //var aqAquisitionServiceClient = new AQAcquisitionServiceClient("WSHttpBinding_IAQAcquisitionService", "http://sooke/AQUARIUS/AqAcquisitionService.svc");
                var authToken = aqAquisitionServiceClient.GetAuthToken("admin", "admin");
                Console.WriteLine("Token: " + authToken);

                using (var contextScope = new OperationContextScope(aqAquisitionServiceClient.InnerChannel))
                {
                    var runtimeHeader = MessageHeader.CreateHeader("AQAuthToken", "", authToken, false);
                    OperationContext.Current.OutgoingMessageHeaders.Add(runtimeHeader);
                    var allLocations = aqAquisitionServiceClient.GetAllLocations();
                    Console.WriteLine("There are " + allLocations.Length + " Locations:");
                    foreach (var location in allLocations)
                    {
                        Console.WriteLine("\t" + location.Identifier);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error occurred: " + ex.ToString());
            }
            Console.WriteLine("Enter to quit...");
            Console.ReadLine();
        }
示例#4
0
        Message OnGetToken(Message input)
        {
            MessageBuffer buf = input.CreateBufferedCopy(10000);

            VerifyInput2(buf);

            // FIXME: create response message (when I understand what I should return.)
//			throw new MyException ();
//*
            XmlDocument doc = new XmlDocument();

            doc.LoadXml("<Response>RESPONSE</Response>");
            X509Certificate2 cert = new X509Certificate2("Test/Resources/test.pfx", "mono");
            SignedXml        sxml = new SignedXml(doc);
            MemoryStream     ms   = new MemoryStream(new byte [] { 1, 2, 3 });

            sxml.AddReference(new Reference(ms));
            sxml.SigningKey = cert.PrivateKey;
            sxml.ComputeSignature();

            Message msg = Message.CreateMessage(input.Version, "http://schemas.xmlsoap.org/ws/2005/02/trust/RSTR/Issue", sxml.GetXml());

            msg.Headers.Add(MessageHeader.CreateHeader(
                                "Security", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", null, true));

            return(msg);
//*/
        }
示例#5
0
        private static void PingChannelFactoryTest()
        {
            string endpointConfigurationName = "BasicHttpBinding_IHelloService";

            BasicHttpBinding binding  = new BasicHttpBinding();
            EndpointAddress  endpoint = new EndpointAddress("http://localhost:8080/HelloService");

            //ChannelFactory<IHelloService> proxy = new ChannelFactory<IHelloService>(endpointConfigurationName);

            ChannelFactory <IHelloService> proxy = new ChannelFactory <IHelloService>(binding, endpoint);

            IHelloService client = proxy.CreateChannel();

            MessageHeader shareableInstanceContextHeader = MessageHeader.CreateHeader(
                "version",
                "http://domain.com",
                "1.0");

            using (var context = new OperationContextScope((IClientChannel)proxy))
            {
                OperationContext.Current.OutgoingMessageHeaders.Add(shareableInstanceContextHeader);
            }


            string result = client.Ping("Hello");

            Console.WriteLine(result);

            client.Send("World");
        }
示例#6
0
        public object BeforeSendRequest(ref System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel)
        {
            
            // Use the WSE 3.0 security token class
            UsernameToken token = new UsernameToken(this.Username, this.Password, PasswordOption.SendHashed);

            // Serialize the token to XML
            XmlDocument xmlDoc        = new XmlDocument();
            XmlElement  securityToken = token.GetXml(xmlDoc);

            // find nonce and add EncodingType attribute for BSP compliance
            XmlNamespaceManager nsMgr = new XmlNamespaceManager(xmlDoc.NameTable);

            nsMgr.AddNamespace("wsse", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
            XmlNodeList  nonces       = securityToken.SelectNodes("//wsse:Nonce", nsMgr);
            XmlAttribute encodingAttr = xmlDoc.CreateAttribute("EncodingType");

            encodingAttr.Value = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary";
            if (nonces.Count > 0)
            {
                nonces[0].Attributes.Append(encodingAttr);
                //nonces[0].Attributes[0].Value = "foo";
            }


            //
            MessageHeader securityHeader = MessageHeader.CreateHeader("Security", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", securityToken, false);

            request.Headers.Add(securityHeader);

            // complete
            return(Convert.DBNull);
        }
        public void TestMessageStateIsValid()
        {
            AdWordsSoapHeaderInspector inspector = new AdWordsSoapHeaderInspector()
            {
                User = new AdWordsUser(),
            };
            RequestHeader requestHeader = new RequestHeader()
            {
                clientCustomerId = "123",
                validateOnly     = true,
                developerToken   = "ABCDEF"
            };

            inspector.RequestHeader = (RequestHeader)requestHeader.Clone();

            ResponseHeader responseHeader = new ResponseHeader()
            {
                operations   = 10,
                responseTime = 1000,
            };

            response.Headers.Clear();
            response.Headers.Add(MessageHeader.CreateHeader("ResponseHeader",
                                                            inspector.RequestHeader.Namespace, responseHeader));

            inspector.BeforeSendRequest(ref this.request, this.channel);
            inspector.AfterReceiveReply(ref this.response, null);

            Assert.AreEqual(MessageState.Created, request.State);
            Assert.AreEqual(MessageState.Created, response.State);
        }
示例#8
0
        /// <summary>
        /// Convert a message via different versions
        /// </summary>
        /// <param name="message">message to convert</param>
        /// <param name="version">required message version</param>
        /// <returns>converted message</returns>
        public static Message ConvertMessage(Message message, MessageVersion version)
        {
            return(CSharpUsageUtility.SafeCreateDisposableObject <Message>(
                       () => Message.CreateMessage(version, message.Headers.Action, message.GetReaderAtBodyContents()),
                       (converted) => {
                int index = message.Headers.FindHeader(Constant.UserDataHeaderName, Constant.HpcHeaderNS);
                if (index >= 0)
                {
                    XmlDictionaryReader reader = message.Headers.GetReaderAtHeader(index);
                    string headerValue = reader.ReadInnerXml();
                    MessageHeader header = MessageHeader.CreateHeader(Constant.UserDataHeaderName, Constant.HpcHeaderNS, headerValue);

                    converted.Headers.Add(header);
                }

                //add messageId header

                index = message.Headers.FindHeader(Constant.MessageIdHeaderName, Constant.HpcHeaderNS);
                if (index >= 0)
                {
                    XmlDictionaryReader reader = message.Headers.GetReaderAtHeader(index);
                    string headerValue = reader.ReadInnerXml();
                    MessageHeader header = MessageHeader.CreateHeader(Constant.MessageIdHeaderName, Constant.HpcHeaderNS, headerValue);

                    converted.Headers.Add(header);
                }

                PrepareAddressingHeaders(message, converted);
            }
                       ));
        }
示例#9
0
        public void OnPremiseResponseReceiver_ReceiveResponse_PreemptionMessage()
        {
            MockDispatcher dispatcher = new MockDispatcher();

            AzureResponseReceiver receiver = new AzureResponseReceiver(dispatcher);

            Message emptyMessage = Message.CreateMessage(MessageVersion.Default, string.Empty);

            Message preemption = Message.CreateMessage(MessageVersion.Default, Constant.HpcHeaderNS);

            preemption.Headers.Add(MessageHeader.CreateHeader(Constant.MessageHeaderPreemption, Constant.HpcHeaderNS, 1));

            DispatchData data = new DispatchData("1", 0, "1")
            {
                BrokerQueueItem = new BrokerQueueItem(null, emptyMessage, null),

                Client = new MockClient()
                {
                    Response = preemption
                }
            };

            receiver.ReceiveResponse(data);

            Assert.AreEqual(data.Exception, null, "Exception is not expected to happen in ReceiveResponse method.");

            Assert.AreEqual(data.ReplyMessage.IsFault, false, "Expected to receive non-fault message ReceiveResponse method.");

            Assert.AreEqual(data.ServicePreempted, true, "Expected to get ServicePreemption notice.");
        }
示例#10
0
        public Dictionary <string, string> LookupContactDetail(decimal contact_id, int _logIncidentId = 0, int _logContactId = 0)
        {
            EBSMockSvcClient            _client = new EBSMockSvcClient(binding, addr);
            ContactListOutputParameters op      = null;

            using (new OperationContextScope(_client.InnerChannel))
            {
                Credential userInfo = new Credential();
                userInfo.username = ContactServiceUsername;
                userInfo.password = ContactServicePassword;

                MessageHeader aMessageHeader = MessageHeader.CreateHeader("Credential", "", userInfo);
                OperationContext.Current.OutgoingMessageHeaders.Add(aMessageHeader);

                op = _client.getContactDetailsByPartyID(contact_id.ToString());
            }

            Dictionary <string, string> dictDetail = new Dictionary <string, string>();

            foreach (ContactPartyItem contact in op.X_CONTACT_LIST)
            {
                foreach (PropertyInfo propertyInfo in contact.GetType().GetProperties())
                {
                    Object propVal = contact.GetType().GetProperty(propertyInfo.Name).GetValue(contact, null);
                    dictAddProperty(propertyInfo, propVal, ref dictDetail);
                }
            }

            return(dictDetail);
        }
示例#11
0
        void TestWriteHeaderContent(object value, string expected)
        {
            MessageHeader       h = MessageHeader.CreateHeader("foo", "bar", value);
            XmlObjectSerializer f = new DataContractSerializer(value.GetType());

            StringBuilder     sb       = new StringBuilder();
            XmlWriterSettings settings = new XmlWriterSettings();

            settings.ConformanceLevel = ConformanceLevel.Auto;
            XmlDictionaryWriter w = XmlDictionaryWriter.CreateDictionaryWriter(
                XmlWriter.Create(sb, settings));

            w.WriteStartElement("dummy-root");
            h.WriteHeaderContents(w, MessageVersion.Soap12WSAddressing10);
            w.WriteEndElement();
            w.Flush();
            string actual2 = sb.ToString();

            sb.Length = 0;
            w.WriteStartElement("dummy-root");
            f.WriteObjectContent(w, value);
            w.WriteEndElement();
            w.Flush();
            string actual1 = sb.ToString();

            // the output of WriteHeaderContent is the same as XmlSerializer.Serialize
            Assert.AreEqual(expected, actual1, "#1");
            Assert.AreEqual(expected, actual2, "#2");
        }
示例#12
0
        /*  call EBSMockSvcClient : GetSRInfoById()
         *  Output : op.X_SR_LIST
         *  call dictAddProperty() to add the individual property name, type, and value
         *  for dynamic columns feature
         */
        public Dictionary <string, string> LookupSRDetail(decimal incident_id, string incident_number, int _logIncidentId = 0, int _logContactId = 0)
        {
            EBSMockSvcClient       _client = new EBSMockSvcClient(binding, addr);
            SRListOutputParameters op      = null;

            using (new OperationContextScope(_client.InnerChannel))
            {
                Credential userInfo = new Credential();
                userInfo.username = SRServiceUsername;
                userInfo.password = SRServicePassword;

                MessageHeader aMessageHeader = MessageHeader.CreateHeader("Credential", "", userInfo);
                OperationContext.Current.OutgoingMessageHeaders.Add(aMessageHeader);

                op = _client.GetSRInfoById(incident_id.ToString());
            }

            Dictionary <string, string> dictDetail = new Dictionary <string, string>();

            foreach (ServiceRequestItem sr in op.X_SR_LIST)
            {
                foreach (PropertyInfo propertyInfo in sr.GetType().GetProperties())
                {
                    Object propVal = sr.GetType().GetProperty(propertyInfo.Name).GetValue(sr, null);
                    dictAddProperty(propertyInfo, propVal, ref dictDetail);
                }
            }

            return(dictDetail);
        }
示例#13
0
        public static DarwinDepartureBoard GetGetEntireBoard(string crs, int offset, int window)
        {
            try
            {
                LDBServiceSoapClient    client = new LDBServiceSoapClient();
                StationBoardWithDetails board  = null;
                using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
                {
                    MessageHeader authHeader = MessageHeader.CreateHeader("AccessToken", @"http://thalesgroup.com/RTTI/2013-11-28/Token/types", DarwinToken.TheAccessToken);
                    OperationContext.Current.OutgoingMessageHeaders.Add(authHeader);

                    //Note that this is called on a background thread - I don't need to make it async. Doing so causes a range of exciting race hazards further on
                    GetDepBoardWithDetailsResponse response = client.GetDepBoardWithDetailsAsync(0, crs, string.Empty, FilterType.from, offset, window).Result;
                    board = (StationBoardWithDetails)response.GetStationBoardResult;
                }
                return(DarwinDepartureBoardFactory.CreateDepartureBoard(board));
            }
            catch (AggregateException ae)
            {
                crashDump(ae);
                return(null);
            }
            catch (System.Runtime.InteropServices.SEHException seh)
            {
                crashDump(seh);
                return(null);
            }
        }
示例#14
0
        private MessageHeader CreateI18nHeader()
        {
            XmlDocument doc = new XmlDocument();

            doc.LoadXml("<locale xmlns=\"http://www.w3.org/2005/09/ws-i18n\">en</locale>");
            return(MessageHeader.CreateHeader("international", "http://www.w3.org/2005/09/ws-i18n", doc.DocumentElement));
        }
示例#15
0
        /// <summary>
        /// Writes the cache directive to the operation context.
        /// </summary>
        /// <param name="directive"></param>
        /// <param name="operationContext"></param>
        protected internal static void WriteCachingDirectiveHeaders(ResponseCachingDirective directive, OperationContext operationContext)
        {
            // add caching directive to WCF message headers so that we send it to the client
            var header = MessageHeader.CreateHeader(HeaderName, HeaderNamespace, directive);

            operationContext.OutgoingMessageHeaders.Add(header);
        }
示例#16
0
 public object BeforeSendRequest(ref Message request, IClientChannel channel)
 {
     Logger.WriteLog(LogType.DEBUG, LoginInfo.Token);
     var tokenHeader = MessageHeader.CreateHeader("Token", "http://tempuri.org/", LoginInfo.Token);
     request.Headers.Add(tokenHeader);
     return null;
 }
示例#17
0
        static void Main(string[] args)
        {
            var homeService = new HomeServiceClient();

            homeService.GetDataContract(new DateTest()
            {
                StrLength = 34
            });

            Console.WriteLine(homeService.GetLength("gaofeng"));

            var secondService = new SecondServiceClient();

            using (OperationContextScope scope = new OperationContextScope(secondService.InnerChannel))
            {
                MessageHeader myHeader = MessageHeader.CreateHeader(
                    "header", "http://my", "你好,这是消息头。");
                OperationContext.Current.OutgoingMessageHeaders.Add(myHeader);

                // 调用方法
                Console.WriteLine(secondService.GetStrLength("jiajia"));
                Console.WriteLine("服务方法已调用。");
            }

            TestChannel();
            TestRestAdd();
            TestMessageContract(homeService);
            TestUploadFile(homeService);
            TestUploadFileWithMessageContract(homeService);
            TestTCPService();
            Console.Read();
        }
示例#18
0
        private void AddSoapHeader(string headerName, string headerValue, string headerNamespace)
        {
            MessageHeader soapHeader = MessageHeader.CreateHeader(headerName,
                                                                  headerNamespace, headerValue);

            OperationContext.Current.OutgoingMessageHeaders.Add(soapHeader);
        }
        public void TestCallEntryAddedToUser()
        {
            AdWordsSoapHeaderInspector inspector = new AdWordsSoapHeaderInspector()
            {
                User          = new AdWordsUser(),
                RequestHeader = new RequestHeader()
            };

            ResponseHeader responseHeader = new ResponseHeader()
            {
                operations   = 10,
                responseTime = 1234,
                serviceName  = "CampaignService",
                methodName   = "mutate"
            };

            response.Headers.Clear();
            response.Headers.Add(MessageHeader.CreateHeader("ResponseHeader",
                                                            inspector.RequestHeader.Namespace, responseHeader));
            inspector.AfterReceiveReply(ref this.response, null);

            ApiCallEntry[] entries = inspector.User.GetCallDetails();
            Assert.AreEqual(1, entries.Length);
            ApiCallEntry entry = entries[0];

            Assert.AreEqual(10, entry.OperationCount);
            Assert.AreEqual("mutate", entry.Method);
            Assert.AreEqual("CampaignService", entry.Service);
        }
示例#20
0
 public Product EbayGet( string id)
 {
     FindingServicePortTypeClient client = new FindingServicePortTypeClient();
     MessageHeader header = MessageHeader.CreateHeader("CustomHeader", "", "");
     using (OperationContextScope scope = new OperationContextScope(client.InnerChannel))
     {
         OperationContext.Current.OutgoingMessageHeaders.Add(header);
         HttpRequestMessageProperty httpRequestProperty = new HttpRequestMessageProperty();
         httpRequestProperty.Headers.Add("X-EBAY-SOA-SECURITY-APPNAME", "XeniaK-comp-PRD-4b4e51644-6f63ec03");
         httpRequestProperty.Headers.Add("X-EBAY-SOA-OPERATION-NAME", "findItemsByKeywords");
         httpRequestProperty.Headers.Add("X-EBAY-SOA-GLOBAL-ID", "EBAY-US");
         OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = httpRequestProperty;
         FindItemsByKeywordsRequest request = new FindItemsByKeywordsRequest();
         request.keywords = id;
         FindItemsByKeywordsResponse response = client.findItemsByKeywords(request);
         if (response.searchResult.count>0  )
         {
             var pr = new Product();
             pr.Title = response.searchResult.item[0].title;
             pr.Url = response.searchResult.item[0].viewItemURL;
             pr.Price = response.searchResult.item[0].sellingStatus.currentPrice.Value.ToString();
             pr.Currentcy = response.searchResult.item[0].sellingStatus.currentPrice.currencyId;
             pr.Id = response.searchResult.item[0].itemId;
             pr.Imageurl = response.searchResult.item[0].galleryURL;
             pr.Name = "Ebay";
             data = pr;
         }
         return data;
     }
 }
示例#21
0
 public static void AddHeader(this Message message, string xsdName, string name, object value)
 {
     if (message.Headers.FindHeader(name, xsdName) <= 0)
     {
         message.Headers.Add(MessageHeader.CreateHeader(name, xsdName, (value == null) ? null : value.ToString()));
     }
 }
示例#22
0
        private bool SendWorkLog(IElmaUser user, IElmaTask task)
        {
            if (!CheckToken() && null == AuthorizeUser(user))
            {
                return(false);
            }

            try {
                var entityService = _entityServiceFactory.CreateChannel();

                using (new OperationContextScope(entityService)) {
                    OperationContext.Current.OutgoingMessageHeaders.Add(MessageHeader.CreateHeader("AuthToken", "",
                                                                                                   AuthToken.ToString
                                                                                                       ()));
                    OperationContext.Current.OutgoingMessageHeaders.Add(MessageHeader.CreateHeader("SessionToken", "",
                                                                                                   SessionToken));

                    entityService.Insert(ElmaWorkLog.WorkLogTypeUid, CreateWorkLogData(user, task));
                }
            }
            catch (FaultException <PublicServiceException> exception) {
                Log.Error("SendWorkLog, FaultException", exception.Message);
                return(false);
            }
            catch (Exception exception) {
                Log.Error("SendWorkLog, Exception", exception.Message);
                return(false);
            }

            return(true);
        }
示例#23
0
        static async public Task <GPSCoordinatesOperationResult> GPSCoordinatesOperationAsync(Guid gpsTrackerEntryId, GPSCoordinatesOperationType operationType, IEnumerable <GPSPoint> points)
        {
            GPSOperationParam dto = new GPSOperationParam();
            var settings          = new JsonSerializerSettings();

            settings.NullValueHandling     = NullValueHandling.Ignore;
            settings.MissingMemberHandling = MissingMemberHandling.Ignore;
            var json  = JsonConvert.SerializeObject(points, settings);
            var bytes = UTF8Encoding.UTF8.GetBytes(json);

            dto.CoordinatesStream = bytes.ToZip();

            GPSOperationData param = new GPSOperationData();

            param.GPSTrackerEntryId = gpsTrackerEntryId;
            param.Operation         = GPSCoordinatesOperationType.UpdateCoordinates;

            var test = exceptionHandling((client) =>
            {
                OperationContext.Current.OutgoingMessageHeaders.Add(MessageHeader.CreateHeader("SessionId", "http://MYBASERVICE.TK/", ApplicationState.Current.SessionData.Token.SessionId));
                OperationContext.Current.OutgoingMessageHeaders.Add(MessageHeader.CreateHeader("Params", "http://MYBASERVICE.TK/", param));
                return(Task <GPSCoordinatesOperationResult> .Factory.FromAsync(client.BeginGPSCoordinatesOperation, client.EndGPSCoordinatesOperation, dto, null));
            });

            return(await test);
        }
示例#24
0
        private WebData[] QueryData(string typeuid, string eqlQuery, string sort, int limit, int offset,
                                    string filterProviderUid, string filterProviderData, string filter)
        {
            var entityService = _entityServiceFactory.CreateChannel();

            try {
                using (new OperationContextScope(entityService)) {
                    OperationContext.Current.OutgoingMessageHeaders.Add(MessageHeader.CreateHeader("AuthToken", "",
                                                                                                   AuthToken.ToString
                                                                                                       ()));
                    OperationContext.Current.OutgoingMessageHeaders.Add(MessageHeader.CreateHeader("SessionToken", "",
                                                                                                   SessionToken));

                    // TODO: findout why QueryAsync throws null exception or make it async another way!
                    return(entityService.Query(typeuid, eqlQuery, sort, limit, offset, filterProviderUid,
                                               filterProviderData, filter));
                }
            }
            catch (FaultException <PublicServiceException> exception) {
                Log.Error("QueryData, FaultException", exception.Message);
                return(null);
            }
            catch (Exception exception) {
                Log.Error("QueryData, Exception", exception.Message);
                return(null);
            }
        }
示例#25
0
       public void HandleMessage(RemoteExitCode message)
       {
           if (this.Disposing || IsDisposed || message.SrcMac == Setting.authorizationInfo.MachineCode)
           {
               return;
           }
           Invoke(new MethodInvoker(() =>
           {
               if (message.Guid != this.Guid)
               {
                   return;
               }
               Mediator.ShowMsg(string.Format("远程机器{0}退出了远程听诊", message.ExitMac));
               if (this.isSender)//广播出去
               {
                   foreach (var mac in this.DgvTable.Select().Select(r => r["MAC"] + "").ToArray().Distinct())
                   {
                       var code = new RemoteExitCode()
                       {
                           Guid    = message.Guid,
                           SrcMac  = Setting.authorizationInfo.MachineCode,
                           DestMac = mac,
                           ExitMac = message.ExitMac
                       };
                       var _bytes = ProtocalData.Utilities.SerializaHelper.Serialize(code);
                       Mediator.SuperSocket.Send(_bytes);
                   }
               }
               else//作为接收者
               {
                   if (message.ExitMac == message.SrcMac)//远程发起者退出
                   {
                       //MessageBox.Show(string.Format("远程听诊关闭了,本窗体即将关闭...编号为{0}", message.Guid));
                       Mediator.ShowMsg(string.Format("远程听诊关闭了,编号为{0}", message.Guid));
                       this.Close();
                       return;
                   }
               }
               //刷新
               string sql = @"select b.StetName,b.MAC,b.PCName,b.StetChineseName,b.Owner from RemoteAuscultateList a left join StethoscopeManager b
 on a.Acceptor=b.StetName and a.MAC=b.MAC where a.SrcGUID={0} and a.isAccept=1 and isExit=0";
               using (OperationContextScope scope = new OperationContextScope(Mediator.remoteService.InnerChannel))
               {
                   MessageHeader header = MessageHeader.CreateHeader("SN", "http://tempuri.org", Setting.authorizationInfo.AuthorizationNum);
                   OperationContext.Current.OutgoingMessageHeaders.Add(header);
                   header = MessageHeader.CreateHeader("MAC", "http://tempuri.org", Setting.authorizationInfo.MachineCode);
                   OperationContext.Current.OutgoingMessageHeaders.Add(header);
                   var ds = Mediator.remoteService.ExecuteDataset(sql, new string[] { this.Guid });
                   if (ds.Tables[0].Rows.Count == 0)
                   {
                       this.Close();
                   }
                   dgvRemote.Rows.Clear();
                   foreach (DataRow row in ds.Tables[0].Rows)
                   {
                       dgvRemote.Rows.Add(row["StetChineseName"], row["StetName"], row["PCName"], row["MAC"], row["Owner"], true);
                   }
               }
           }));
       }
        static Message CreateMessageWithTo(Uri to)
        {
            Message msg = Message.CreateMessage(MessageVersion.Default, "urn:myaction");

            msg.Headers.Add(MessageHeader.CreateHeader("To", "http://www.w3.org/2005/08/addressing", to));
            return(msg);
        }
示例#27
0
 /// <summary>
 /// Encodes the Wulka context.
 /// </summary>
 /// <param name="ctx">The CTX.</param>
 /// <param name="reply">The reply.</param>
 internal static void EncodeWulkaContext(WulkaContext ctx, ref Message reply)
 {
     foreach (string key in ctx.Keys)
     {
         reply.Headers.Add(MessageHeader.CreateHeader(key, ServiceConst.ContextNamespace, ctx[key]));
     }
 }
示例#28
0
        string MAC = "20:47:47:C8:CB:42";                    //System.Configuration.ConfigurationManager.AppSettings["MAC"];

        void FrmMain_Load(object sender, EventArgs e)
        {
            using (OperationContextScope scope = new OperationContextScope(remoteService.InnerChannel))
            {
                MessageHeader header = MessageHeader.CreateHeader("SN", "http://tempuri.org", SN);
                OperationContext.Current.OutgoingMessageHeaders.Add(header);
                header = MessageHeader.CreateHeader("MAC", "http://tempuri.org", MAC);
                OperationContext.Current.OutgoingMessageHeaders.Add(header);
                string sql = @"SELECT  * FROM " + VersionMajor + " WHERE Enable=1";
                var    ds  = remoteService.ExecuteDataset(sql, null);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    var banben  = ds.Tables[0].Rows[0]["Version"] + "";
                    var content = ds.Tables[0].Rows[0]["PubContent"] + "";
                    sql = @"SELECT Value FROM SysConst WHERE KeyName='" + Key + "'";
                    var Dir = remoteService.ExecuteScalar(sql, null);
                    //var majorDir = Dir + "\\" + banben;
                    var majorDir = Dir;
                    //sql = "select * from View_CurrentVersion ";
                    //var dsFile = remoteService.ExecuteDataset(sql, new string[] { });
                    //int i = 0;
                    lblVersion.Text = "版本:V" + banben;
                    lblConetnt.Text = "更新内容:" + content;
                    Down(majorDir);
                }
            }
        }
        object IClientMessageInspector.BeforeSendRequest(ref Message request, IClientChannel channel)
        {
            var header = MessageHeader.CreateHeader(HeaderName, HeaderNamespace, CustomDataContext.Header);

            request.Headers.Add(header);
            return(null);
        }
示例#30
0
        public EnumerateResponse Enumerate(EnumerationRequest request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }

            Message enumerateRequest = null;

            lock (request) {
                enumerateRequest = Message.CreateMessage(MessageVersion.Default, Constants.WsEnumeration.EnumerateAction, request, new ClientSerializer(typeof(EnumerationRequest)));
                // PATCHED: adding the "IncludeCount" header
                // Must add an "IncludeCount" message header to get the total
                // number of matching objects in the response.
                MessageHeader includeCount = MessageHeader.CreateHeader(
                    "IncludeCount", Constants.Rm.Namespace, null);
                enumerateRequest.Headers.Add(includeCount);
            }
            Message enumerateResponse = Enumerate(enumerateRequest);

            if (enumerateResponse.IsFault)
            {
                // handle fault will throw a .NET exception
                ClientHelper.HandleFault(enumerateResponse);
            }

            EnumerateResponse enumerateResponseTyped = enumerateResponse.GetBody <EnumerateResponse>(new ClientSerializer(typeof(EnumerateResponse)));

            return(enumerateResponseTyped);
        }