Esempio n. 1
0
        public Response(WebResponse response)
        {
            m_status_code = (int)((HttpWebResponse)response).StatusCode;
            m_status_desc = ((HttpWebResponse)response).StatusDescription;
            // Get the response.
            Stream dataStream;

            dataStream = response.GetResponseStream();
            // Open the stream using a StreamReader for easy access.
            StreamReader reader = new StreamReader(dataStream);

            // Read the content.
            m_response_text = reader.ReadToEnd();
            // Clean up the streams.
            reader.Close();
            dataStream.Close();
            if (m_status_code == 200)
            {
                m_json_response = (JsonObject)JsonConvert.Import(m_response_text);
                if ((string)m_json_response["type"] == "jsonwsp/description")
                {
                    m_jsonwsp_type = JsonWspType.Description;
                    m_call_result  = CallResult.Success;
                }
                if ((string)m_json_response["type"] == "jsonwsp/response")
                {
                    m_jsonwsp_type = JsonWspType.Response;
                    m_call_result  = CallResult.Success;
                }
                if ((string)m_json_response["type"] == "jsonwsp/fault")
                {
                    m_jsonwsp_type = JsonWspType.Fault;
                    m_call_result  = CallResult.ServiceFault;
                    JsonObject jsonwsp_fault = (JsonObject)m_json_response["fault"];
                    m_fault = new Fault(jsonwsp_fault);
                }
            }
            else
            {
                m_jsonwsp_type = JsonWspType.NoType;
                m_call_result  = CallResult.NetworkFault;
            }
        }
Esempio n. 2
0
 public Response(WebResponse response)
 {
     m_status_code = (int) ((HttpWebResponse)response).StatusCode;
     m_status_desc = ((HttpWebResponse)response).StatusDescription;
     // Get the response.
     Stream dataStream;
     dataStream = response.GetResponseStream ();
     // Open the stream using a StreamReader for easy access.
     StreamReader reader = new StreamReader (dataStream);
     // Read the content.
     m_response_text = reader.ReadToEnd ();
     // Clean up the streams.
     reader.Close();
     dataStream.Close();
     if (m_status_code==200) {
         m_json_response = (JsonObject) JsonConvert.Import(m_response_text);
         if ((string)m_json_response["type"]=="jsonwsp/description") {
             m_jsonwsp_type = JsonWspType.Description;
             m_call_result = CallResult.Success;
         }
         if ((string)m_json_response["type"]=="jsonwsp/response") {
             m_jsonwsp_type = JsonWspType.Response;
             m_call_result = CallResult.Success;
         }
         if ((string)m_json_response["type"]=="jsonwsp/fault") {
             m_jsonwsp_type = JsonWspType.Fault;
             m_call_result = CallResult.ServiceFault;
             JsonObject jsonwsp_fault = (JsonObject) m_json_response["fault"];
             m_fault = new Fault(jsonwsp_fault);
         }
     }
     else {
         m_jsonwsp_type = JsonWspType.NoType;
         m_call_result = CallResult.NetworkFault;
     }
 }