Click here to Skip to main content
15,887,683 members
Home / Discussions / ASP.NET
   

ASP.NET

 
SuggestionRe: MVC Razor, routevalues [solved] Pin
Richard Deeming5-Feb-16 4:37
mveRichard Deeming5-Feb-16 4:37 
GeneralRe: MVC Razor, routevalues [solved] Pin
jkirkerx5-Feb-16 6:28
professionaljkirkerx5-Feb-16 6:28 
QuestionDetailsView - Dropdown in ItemTemplate Pin
Member 121716134-Feb-16 2:51
Member 121716134-Feb-16 2:51 
QuestionRe: DetailsView - Dropdown in ItemTemplate Pin
ZurdoDev4-Feb-16 4:17
professionalZurdoDev4-Feb-16 4:17 
AnswerRe: DetailsView - Dropdown in ItemTemplate Pin
Member 121716134-Feb-16 4:36
Member 121716134-Feb-16 4:36 
GeneralRe: DetailsView - Dropdown in ItemTemplate Pin
ZurdoDev4-Feb-16 4:51
professionalZurdoDev4-Feb-16 4:51 
AnswerRe: DetailsView - Dropdown in ItemTemplate Pin
Richard Deeming4-Feb-16 4:35
mveRichard Deeming4-Feb-16 4:35 
QuestionPhone system dashboard (Broadsoft) Pin
dannyvkempen3-Feb-16 21:15
dannyvkempen3-Feb-16 21:15 
Hi All,

I am trying to build an telephone central dashboard (broadsoft).
This system is using httpwebrequests to select data.

First i need to build an channel to broadsoft. This works correct. I do get an channelId and expire time back from this server.

Then i would like to subscribe an event over this channel. When i try that i get an error that the channel that i just made doesn't exist (expiry time for this channel did not expired).

This is my code:

1. URL
C#
public DataSet EventRequest(string request, string id = null)
    {
        string method = string.Empty;
        string url = string.Empty;
        string xml = string.Empty;
        bool chunked = false;

        switch (request)
        {
            case "CreateEventChannel":
                method = "POST";
                url = "http://xsp.voipit.nl/com.broadsoft.async/com.broadsoft.xsi-events/v2.0/channel/";
                xml = "<?xml version='1.0' encoding='UTF-8'?><Channel xmlns='http://schema.broadsoft.com/xsi'><channelSetId>SomeChannelSetId</channelSetId><priority>1</priority><weight>50</weight><expires>3600</expires></Channel>";
                chunked = true;
                break;             
            case "CreateSubscription":
                method = "POST";
                url = "http://xsp.voipit.nl/com.broadsoft.xsi-events/v2.0/user/<userId>";
                xml = "<?xml version='1.0' encoding='UTF-8'?><Subscription xmlns='http://schema.broadsoft.com/xsi'> <targetIdType>User</targetIdType> <event>Standard Call</event> <expires>300000</expires> <channelSetId>SomeChannelSetId</channelSetId> <applicationId>SomeApplicationId</applicationId></Subscription>";
                break;
            default:
                url = "";
                break;
        }

        return GetData(url, method, xml, chunked);
    }


2. Request method
C#
public DataSet GetData(string destinationUrl, string method = null, string requestXml = null, bool chunked = false)
    {
        string output = string.Empty;
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(destinationUrl);
        request.ProtocolVersion = HttpVersion.Version10;
        request.KeepAlive = true;
        request.Timeout =
        request.ReadWriteTimeout = 60000;
        request.Accept = @"application/xml";
        request.PreAuthenticate = true;
        request.ContentType = "application/xml; encoding='utf-8'";        
        request.SendChunked = chunked;
        request.Method = method;        
        request.Credentials = new NetworkCredential(WebConfigurationManager.AppSettings["Username"], WebConfigurationManager.AppSettings["Password"]);
        
        if (requestXml != string.Empty)
        {
            byte[] bytes;
            bytes = System.Text.Encoding.ASCII.GetBytes(requestXml);
            request.ContentLength = bytes.Length;
            Stream requestStream = request.GetRequestStream();
            requestStream.Write(bytes, 0, bytes.Length);            
        }      

        return CreateRequestDataSet(request);
    }


3. Get data
C#
public DataSet CreateRequestDataSet(HttpWebRequest request)
    {
        string output = string.Empty;
        HttpWebResponse response = null;
        try
        {
            response = (HttpWebResponse)request.GetResponse();
            WebHeaderCollection header = response.Headers;
            string StatusCode           = Convert.ToString(response.StatusCode);
            string StatusDescription    = response.StatusDescription;            
        }
        catch (WebException e)
        {
            using (WebResponse responseTest = e.Response)
            {
                HttpWebResponse httpResponse = (HttpWebResponse)responseTest;
                string ErrorCode = httpResponse.StatusCode.ToString();
                using (Stream data = responseTest.GetResponseStream())
                using (var reader = new StreamReader(data))
                {
                    string ErrorResponse = reader.ReadToEnd();                    
                }
            }
        }

        try
        {
            var encoding = ASCIIEncoding.UTF8;
            using (var reader = new System.IO.StreamReader(response.GetResponseStream(), encoding))
            {
                output = reader.ReadToEnd();
            }
        }
        catch (Exception) { }


        DataSet ds = new DataSet();
        DataTable dt = new DataTable();
        using (StringReader stringReader = new StringReader(output))
        {
            if (output != string.Empty)
            {
                ds = new DataSet();
                try
                {
                    ds.ReadXml(stringReader);
                }
                catch (Exception) { }
            }
        }

        return ds;
    }



Can someone maybe tell me why my channel doesn't exist anymore when i call CreateSubscriptionConfused | :confused:
AnswerRe: Phone system dashboard (Broadsoft) Pin
Richard Deeming4-Feb-16 1:36
mveRichard Deeming4-Feb-16 1:36 
QuestionPopulate word with data Pin
Praveen Kandari3-Feb-16 0:05
Praveen Kandari3-Feb-16 0:05 
AnswerRe: Populate word with data Pin
Nathan Minier3-Feb-16 1:17
professionalNathan Minier3-Feb-16 1:17 
GeneralRe: Populate word with data Pin
Praveen Kandari3-Feb-16 1:20
Praveen Kandari3-Feb-16 1:20 
GeneralRe: Populate word with data Pin
Nathan Minier3-Feb-16 2:21
professionalNathan Minier3-Feb-16 2:21 
GeneralRe: Populate word with data Pin
Praveen Kandari3-Feb-16 18:11
Praveen Kandari3-Feb-16 18:11 
GeneralRe: Populate word with data Pin
Richard Deeming4-Feb-16 1:31
mveRichard Deeming4-Feb-16 1:31 
GeneralRe: Populate word with data Pin
Nathan Minier4-Feb-16 3:21
professionalNathan Minier4-Feb-16 3:21 
QuestionProblem with Post request in my ASP.NET Web API + jQuery Pin
Farhad Eft2-Feb-16 12:18
Farhad Eft2-Feb-16 12:18 
AnswerRe: Problem with Post request in my ASP.NET Web API + jQuery Pin
F-ES Sitecore2-Feb-16 23:10
professionalF-ES Sitecore2-Feb-16 23:10 
QuestionLinq to Sql: How to Fetch specific row using store procedure and display columns data into textboxes Pin
Ahmer Ali Ahsan Sheikh2-Feb-16 7:38
Ahmer Ali Ahsan Sheikh2-Feb-16 7:38 
QuestionAll my Telterik Control became disabled Pin
indian1431-Feb-16 10:42
indian1431-Feb-16 10:42 
AnswerRe: All my Telterik Control became disabled Pin
ZurdoDev2-Feb-16 8:41
professionalZurdoDev2-Feb-16 8:41 
QuestionI am getting following Telerik errors when Compiling the Application Pin
indian1431-Feb-16 7:31
indian1431-Feb-16 7:31 
AnswerRe: I am getting following Telerik errors when Compiling the Application Pin
Brisingr Aerowing1-Feb-16 9:09
professionalBrisingr Aerowing1-Feb-16 9:09 
GeneralSource code project for complex event processing Pin
Member 1185956231-Jan-16 19:55
Member 1185956231-Jan-16 19:55 
SuggestionRe: Source code project for complex event processing Pin
Richard MacCutchan31-Jan-16 21:25
mveRichard MacCutchan31-Jan-16 21:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.