Wednesday, 18 September 2013

In android always execute catch block it doesent call method from the zend

In android always execute catch block it doesent call method from the zend

Hello all i am trying to accees zend xmlrpc method in to android but it
always execute catch block is there any help... follwing is my code.
Android code Following is my android code for calling zend xmlapi.
below code pass url and call the method from the zend framework to the
test method of below activity it set the text value return from the zend
framework test method.
public class ClientActivity extends Activity {
private XMLRPCClient client;
private URI uri;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_client);
System.out.println("Hello world");
uri = URI.create("http://10.0.2.2/tz/Examp2.php/api/?wsdl");
client = new XMLRPCClient(uri);
TextView textView = (TextView) findViewById(R.id.text_view);
textView.setText(testMethod());
}
private String testMethod() {
String text = "";
try {
text = (String) client.call("cmd.test");
} catch (XMLRPCException e) {
Log.w("XMLRPC Test", "Error", e);
text="Some error";
}
return text;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is
present.
getMenuInflater().inflate(R.menu.client, menu);
return true;
}
}
and at zend side code my code is following which contain xml rpc server
it will return string value to the android device.
<?php
class Examp2Controller extends Zend_Controller_Action
{
public function init()
{
/* Initialize action controller here */
}
public function indexAction()
{
$this->_helper->viewRenderer->setNoRender();
$server = new Zend_XmlRpc_Server();
$server->setClass('Application_Model_Students', 'cmd');
echo $server->handle();
}
}
// This is a model code.
which contain one test method that i am trying to call
<?php
class Application_Model_Students
{
/**
* Test method
*
* @return string
*/
public function test()
{
return 'Hello XMLRPC!';
}
}

Adding a new array element to a JSON object

Adding a new array element to a JSON object

I have a JSON format object I read from a JSON file that I have in a
variable called teamJSON, that looks like this:
{"theTeam":[{"teamId":"1","status":"pending"},{"teamId":"2","status":"member"},{"teamId":"3","status":"member"}]}
I want to add a new item to the array, such as
{"teamId":"4","status":"pending"}
to end up with
{"theTeam":[{"teamId":"1","status":"pending"},{"teamId":"2","status":"member"},{"teamId":"3","status":"member"},{"teamId":"4","status":"pending"}]}
before writing back to the file. What is a good way to add to the new
element? I got close but all the double quotes were escaped. I have looked
for a good answer on SO but none quite cover this case. Any help is
appreciated.

Java code not reading arguments

Java code not reading arguments

For a class that I have, I have to take arguments, which will be files
with different urls on each line, and run through the lines to count the
amount of times each url has different schemes and different domains. If
there is no argument, than I have to scan in directly what is typed. I
have gotten the following code, which includes everything except the
printlns at the end.
import java.util.Scanner;
public class P1 {
public static void main(String[] args){
int fileLinesCt=0, totalLinesCt=0;
int httpCt=0, httpsCt=0, ftpCt=0, otherSchemeCt=0;
int eduCt=0, orgCt=0, comCt=0, otherDomainCt=0;
String url, scheme, schemeSP, domain = null;
Scanner scan = null;
if(!args.equals(null)){
for (int j=0; j<args.length; j++){
scan = new Scanner(args[j]);
fileLinesCt = 0;
while (!"end".equals(scan.nextLine())){
url = scan.nextLine();
String[] parts = url.split("//://");
scheme = parts[0];
schemeSP = parts[1];
if ("http".equals(scheme))
httpCt++;
if ("https".equals(scheme))
httpsCt++;
if ("ftp".equals(scheme))
ftpCt++;
else otherSchemeCt++;
for (int i=0; i<schemeSP.length(); i++){
if (schemeSP.charAt(j) == '.')
domain = schemeSP.substring(j,'/');
if (schemeSP.charAt(j) == '/')
break;
}
if ("edu".equals(domain))
eduCt++;
if ("org".equals(domain))
orgCt++;
if ("com".equals(domain))
comCt++;
else otherDomainCt++;
fileLinesCt++;
totalLinesCt++;
if (fileLinesCt == 1)
System.out.println(">> Got " + fileLinesCt + " line from "
+ scan);
else System.out.println(">> Got " + fileLinesCt + " lines from
" + scan);
}
}
}
else {
Scanner scanner = new Scanner(System.in);
fileLinesCt = 0;
while (!scanner.next().equals("end")){
url = scanner.next();
String[] parts = url.split("//://");
scheme = parts[0];
schemeSP = parts[1];
if ("http".equals(scheme))
httpCt++;
if ("https".equals(scheme))
httpsCt++;
if ("ftp".equals(scheme))
ftpCt++;
else otherSchemeCt++;
for (int j=0; j<schemeSP.length(); j++){
if (schemeSP.charAt(j) == '.')
domain = schemeSP.substring(j,'/');
if (schemeSP.charAt(j) == '/')
break;
}
if ("edu".equals(domain))
eduCt++;
if ("org".equals(domain))
orgCt++;
if ("com".equals(domain))
comCt++;
else otherDomainCt++;
fileLinesCt++;
totalLinesCt++;
if (fileLinesCt == 1)
System.out.println(">> Got " + fileLinesCt + " line from "
+ scan);
else System.out.println(">> Got " + fileLinesCt + " lines from
" + scan);
}
}
When running the code, I get an error that says
"Program failed when listing file(s) on command line.
Exception in thread "main" java.util.NoSuchElementException: No line
found" This occurs at line 15 when it tries to scan the next line.
What am I doing wrong that would stop it from scanning the next line?

Multiple buttons on an html page to reveal text step by step rather than simultaneously?

Multiple buttons on an html page to reveal text step by step rather than
simultaneously?

trying to create a list of about 7 questions with a click to reveal answer
button next to each question. only problem is when i click one button, it
runs the entire js code and shows ALL the answers not just that particular
one.
here is my code
Question 1 $("form").submit(function() { $("#reveal-space").text("Answer
1").show(); return true; }); Question 2 $("form").submit(function() {
$("#reveal-space1").text("Answer 2").show(); return true; }); Question 3
$("form").submit(function() { $("#reveal-space2").text("Answer 3").show();
return true; }); Question 4 $("form").submit(function() {
$("#reveal-space3").text("Answer 4").show(); return true; });
how do i fix it to make it so that when the "1" button is clicked it
doesn't reveal the texts to the other buttons ? i may need to take an
entirely different approach
thanks for the help in advance

Imaginary units of complex numbers dropped by 'knitr'

Imaginary units of complex numbers dropped by 'knitr'

I came across a strange issue in 'knitr' with R code containing complex
numbers entered directly using the "x + yi" notation. For an illustration
see the minimal example: http://goo.gl/Yj77kI
The sample code evaluates correctly, both in R console and as a code chunk
when compiled with Sweave, resulting in:
> 1i^2
[1] -1+0i
However, when trying to use 'knitr' on the same document, the imaginary
unit seems to get lost and what I get is:
1^2
## [1] 1
Any ideas?
Cheers, Andrzej

importing multiple text files into multiple tables using ssis

importing multiple text files into multiple tables using ssis

Q: I have multiple text files in a folder named xyz, and i have created a
new database in sqlserver which does not having any tables .Here my
problem is to import all those text files into new database according to
the text file named tables using ssis package .can anyone knows please
tell me the steps.
A: Step 1: Use foraech loop iterator to pick all files in the specific
folder. Step 2: By using script task get the column name from text file
and create the tables in you database. Keep the table name in the SSIS
variable. Step 3: Choose any destination task and insert the data into the
newly created tables.
I used foreach loop container and selected the path of text files .in step
2 am unable to write the script for the column import .i have couple of
text files named employee having columns id ,name and another one
department having deptno ,location . Actually am a beginner to sql server
and ssis too.can anyone knows please help me

source folders not visible in Netbeans project after installing jRebel plugin?

source folders not visible in Netbeans project after installing jRebel
plugin?

I installed jRebel on Netbeans and this made all my source folders an
libraries to disappear from my projects - except Maven ones. Like this:

The source folders are still present on my drive:

I just need to restore their visibility in my opened Netbeans projects.
When I try to add source packages from the "Properties" menu of the
project, I do get the source back but as folders, not packages.
Help would be much appreciated!