Пример #1
0
 private SoapEnvelope BuildSoapEnvelope(string action)
 {
     SoapEnvelope soap = new SoapEnvelope();
     soap.Header.WsaAction = action;
     soap.Header.WsaFrom = new EndPointReference();
     soap.Header.WsaFrom.Address = _appName;
     return soap;
 }
Пример #2
0
        public void SendMessageAsync(SoapEnvelope soap, bool expectResponse)
        {
            try
            {
                byte[] dataArray = SerializationHelper.SerializeObject(soap);
                // get array length
                int reqLen = dataArray.Length;

                // convert length value to network order
                int reqLenH2N = IPAddress.HostToNetworkOrder(reqLen);

                // get length value into a byte array -- for use with
                // Socket.Send
                byte[] reqLenArray = BitConverter.GetBytes(reqLenH2N);

                // send the length value
                _clientSocket.Send(reqLenArray, 4, System.Net.Sockets.SocketFlags.None);

                // send the byte array
                _clientSocket.Send(dataArray, reqLen, System.Net.Sockets.SocketFlags.None);
                if (!_isWaitingMessage && expectResponse)
                {
                    _isWaitingMessage = expectResponse;
                    if (_clientSocket.Connected)
                    {
                        //Wait for data asynchronously
                        WaitForHeader();
                    }
                }
            }
            catch (Exception ex)
            {
                _bkClient.ExceptionCaught(ex);
            }
        }