cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1940
Views
0
Helpful
23
Replies

Call a StringBuffer type

I created a html file on an external http server for a form post method, like this:

<HTML>

<HEAD>

<TITLE>Cisco XML DB Access Function</TITLE>

</SCRIPT>

</HEAD>

<BODY>

<CENTER>

<FORM METHOD="post" action="http://172.31.254.248:9080/DBAccess">

<DIV>UCCX HTTP Triggering - DB Access<P>

User ID Number:

<INPUT NAME="UserID" TYPE="text" SIZE="20">

<INPUT TYPE="submit" VALUE="Send"></DIV>

</FORM>

</CENTER>

</BODY>

</HTML>

but I'll like to integrate this lines into script .aef file, so I created variable named buffer as StringBuffer type with this value:

{

StringBuffer buffer = new StringBuffer(300);

buffer.append("<CiscoIPPhoneInput>");

buffer.append("<Title>Cisco XML DB Access Function</Title>");

buffer.append("<Prompt>Please Enter your User ID</Prompt>");

buffer.append("<URL>http://172.31.254.248:9080/DBAccess</URL>");

buffer.append("<InputItem>");

buffer.append("<DisplayName>User ID: </DisplayName>");

buffer.append("<QueryStringParam>UserID</QueryStringParam>");

buffer.append("<DefaultValue></DefaultValue><InputFlags>N</InputFlags>");

buffer.append("</InputItem>");

buffer.append("</CiscoIPPhoneInput>");

return buffer;

}

But I have a problem on how to call this lines to be executed before Get Http Contact Info, how shuld I call this lines??

Regards,

2 Accepted Solutions

Accepted Solutions

Hi,

... this is why I am trying to tell you to understand the basics of HTTP and HTML first, before actually trying scripting it.

There will be two request-response pairs. It's up to you how you script it in UCCX, but basically, this is how it works - let's stick to HTML for now:

1. client sends HTTP request;

2. server sends HTTP response: the form page;

3. client sends HTTP request with GET or POST parameters;

4. server sends HTP response: the result page.

How many requests are there in your script? One. The one actually triggers your script.

How many responses are you trying to serve? Two. One will get through. The second won't.

What you can do: implement one trigger-application-script for the first request-response pair, and implent a second trigger-application-script for the second request-response pair.

Or, you can do it with one script, as I did with my LDAP lookup service script. The script is actually intelligent enough to see by the GET parameter, which response is appropriate.

Again, first try to understand the basics. Scripting without knowledge will never yield the expected result.

G.

View solution in original post

Hi

If the phone rejects it, it's usually because your XML isn't perfect. The phones are VERY particular, and really pretty dumb.

I would browse to the page, use firefox with firebug, or chrome and inspect what comes back. Make sure it returns text/xml content type, and make sure the XML is parseable.

Aaron

Aaron Please remember to rate helpful posts to identify useful responses, and mark 'Answered' if appropriate!

View solution in original post

23 Replies 23

Aaron Harrison
VIP Alumni
VIP Alumni

Hi

I would stick this whole chunk in a 'set' step, with the step set to set a String variable to the return value:

{

StringBuffer buffer = new StringBuffer(300);

buffer.append("");

buffer.append("Cisco XML DB Access Function");

buffer.append("Please Enter your User ID");

buffer.append("http://172.31.254.248:9080/DBAccess");

buffer.append("");

buffer.append("User ID: ");

buffer.append("UserID");

buffer.append("N");

buffer.append("");

buffer.append("");

return buffer.toString();

}

Note I've just returned the result of the toStrign() method on your buffer.

E.g.

Set

Variable: mystring

Value:

Aaron Please remember to rate helpful posts to identify useful responses, and mark 'Answered' if appropriate!

Hi Aaron, I tried that way but I'm doing something wrong, or something is missing, the variable buffer is mapped as Headers on Get Http Contact Info, is it right??  I don't understand yet the syntax for this, can you help me with a simple example!?  Also, after doing a query to DB, how to a display the results?

Thanks for your time,

Er... yes, you are doing it wrong.

With the use of the Get HTTP Contact Info step, you get the header values, parameters etc - the client, the browser sent this.

If you want to send your buffer to the client, the browser, you need to use the Send HTTP response step.

I see what you are aiming at but to be quite honest with you, I would like you to have the great feeling of learning something on your own. Try to think the whole process over, again, take out a piece of paper and a pencil and try to sketch up the request - response process.

G.

Hi Gergely, sorry if it bothers you all my questions, I accept that I'm very confuse on this language programming, even any other, but I had read on Internet and there is not much information, I had tried with Send HTTP response as you said configuring "(Document)buffer.toString()" on Document filed but nothing does.

Don't telling you to solve my problem, just asking for some ideas where to look at, or correct syntax to use.

Thanks for your time,

Hi,

can you please explain what are you trying to achieve. It looks like you are mixing a standard HTML and an XML file.

Who is going to be the server? UCCX? Or somebody else, too?

Who is going to be the client? A phone? A regular web browser?

Can you describe the process in your own words?

We are ready to help you but I have a feeling you are not quite sure what is it exactly you are trying to do.

Thanks.

G.

Hello Gergely, thanks again and sorry if I haven't been clear enough with my past requests, but as I told you before I'm starting doing this.  Let me explain what I'm trying to do, days before you also help me with a script to make a query to a DB and send an email to caller, this process it's working with using call trigger and works like this, end user calls to a number and a prompt request for his UserID and PIN, and if it's ok he listens to the ammount of money of an account, finally CCX sends an email with this information to end user.

Now, what I'm looking for is to do this same process as a http trigger, first as a test, I created a html code like this:

Cisco XML DB Access Function

http://172.31.254.248:9080/DBAccess">

UCCX HTTP Triggering - DB Access

User ID Number:

Making a debug, it's received the UserID, the query is executed based on this UserID, information from DB is mapped to variables, buy my problem is to display this code as XML code, I mean the initial XML page and final XML page with results.  Until now this is what I got, it's very simple.

And this is the Value from variable buffer:

{

StringBuffer buffer = new StringBuffer(300);

buffer.append("");

buffer.append("");

buffer.append("Cisco XML DB Access Function");

buffer.append("Please Enter your User ID");

buffer.append("http://172.31.254.248:9080/DBAccess");

buffer.append("");

buffer.append("User ID: ");

buffer.append("UserID");

buffer.append("N");

buffer.append("");

buffer.append("");

return buffer.toString();

}

From the output file with results, really don't have an idea how to do it, I think it's with append. command.

Hope to clear, and notice that I'm making an effort to make it, just need a little assistance to continue.

Thanks for your time and patience.

Regards,

I made some changes and finally I got displayed the initial XML code on ephone, I just need some help on output XML code with results, any idea will be very helpful, thanks.

This is what I got until now:

Hi,

well call me an idiot but I don't understand why you are generating an XML for a Cisco phone.

You wrote you want a standard web page and if someone fills in some information, a database query is performed and finally an email is sent. I don't really understand the IP phone part.

G.

Hi Gergely, the part that you said is for a call trigger, with a phone call, which it's working fine, but now I'm looking this same process for a http trigger using a Cisco phone, and I told you about html files just to test, but at the end I'm looking for XML files into .aef file.

Regards,

Hi,

well, I don't see the point of mixing HTML and XML - you should decide whether to write an HTML or an XML app.

What you need is two pages:

1. the form,

2. the result.

Both can be served by UCCX.

In fact, the form is most likely a static page, with no dynamic content, so I don't see any reason why you want to craft it using Strings and StringBuffers, instead of just creating it in an XML Editor - even notepad would do.

This form page would be served upon first contact. As we can see, you chose the HTTP POST method, which is fine; although the GET method would be easier to read (GET parameters are in the URL so you can mimic them easily).

Second, a Get HTTP Info step in UCCX is there to collect all these parameters, be them GET or POST. You usually map these to local variables. With these variables you do what you desire, perform database queries, send emails, whatever. Then you can craft another HTML page, the "result" with some dynamic information, and send it back using the Send HTTP response step.

I recommend you learn the basics of HTML and HTTP - especially the way forms work.

Then, try to create a HTML application - this is what you can test with a web browser.

Then, try to explore the IP Phone Services SDK - converting a HTML application to an XML format the Cisco IP phone understands would be easy, then.

About the DBAccess.aef script - referring to the screenshot - it contains a huuuuge logical rollercoaster. You call the script using HTTP. You send HTTP Response (that buffer thingie). I mean, the client, the web browser gets that HTML, and that's it, period, full stop, finito, end of the road. Yes, the script will run happily, will perform database queries, and all that stuff, but you can call Send HTTP Response as many times as you want, it will never reach the client. Why? Think about it. Did the client send a request? Yes. Did the client got a response? Yes (that first one). Would it ever "read" what you "send" in the second Send HTTP response? Noooo freakin' way.

G.

Gergely, I'm trying to explain that HTML files are just to test, for a lab, and then after it's working do it in XML files.  I don't want to use a XML editor cause this won't be helpful for me, I'm not an expert as you're. And yes, the DBAccess.aef script is not finished yet, I just wanted to post it to show what I got by the moment. Now I'm just looking the result.

You said:

Would it ever "read" what you "send" in the second Send HTTP response? Noooo

I'm sorry, but what do I need for this??  I'm inserting (after DB Read) a new Send Http Response, but the display  on phone it's not cleared to display the "result" with some dynamic  information, how can  I display the new text??  What command can I use to use a Send Http  Response after another one??

Regards,

Hi,

... this is why I am trying to tell you to understand the basics of HTTP and HTML first, before actually trying scripting it.

There will be two request-response pairs. It's up to you how you script it in UCCX, but basically, this is how it works - let's stick to HTML for now:

1. client sends HTTP request;

2. server sends HTTP response: the form page;

3. client sends HTTP request with GET or POST parameters;

4. server sends HTP response: the result page.

How many requests are there in your script? One. The one actually triggers your script.

How many responses are you trying to serve? Two. One will get through. The second won't.

What you can do: implement one trigger-application-script for the first request-response pair, and implent a second trigger-application-script for the second request-response pair.

Or, you can do it with one script, as I did with my LDAP lookup service script. The script is actually intelligent enough to see by the GET parameter, which response is appropriate.

Again, first try to understand the basics. Scripting without knowledge will never yield the expected result.

G.

Hi, with your recommendations the http trigger with html files is now working, it's clear the way it's works, so now I got this:

and a html file with this text, and replaced it with variables values read it from DB:

%OutgetFirstName%

%OutgetLastName%

%OutgetBalance%

But, doing a similar way for XML files, it's not working yet.

As before, I appreciate any new idea that someone could give me to finally get this working.

Regards,

I made the following test and debugs and it's a little detail that it's getting me crazy:

1. Debugging using a Cisco phone with xml files (http trigger), the input value is received in the form, the query to DB is made, values are mapped but not displayed.

2. Debugging using a browser with html file as the form, and xml file as the result, the values are displayed correctly.

So, I think the problem could it be the Cisco phone (Cisco 8941) or the form xml file used. Cause the problem seams that the form is displayed, but for some reason the results are not.

Is there a way to force the output??  Or maybe some command that it's missing??  Please look at the screenshot from previous post.

I'm very close to get it, I appreciate a little help to fix this.

This is the XML file for the form:

Cisco XML DB Access Function

Please Enter your User ID (Expediente)

http://172.31.254.248:9080/DBAccess

  User ID (Expediente):

  UserID

  18989

  N

This is the XML output file that I'm using for the results:

Account Information

Cisco XML DB Access Function

First Name: %OutgetFirstName%

Last Name: %OutgetLastName%

Balance: %OutgetBalance%

Regards,