Searching a key word with java client programme from wsdl - java

Heyy I have a problem
I generated a client programme using http://api.search.live.net/search.wsdl this service for searching a key words..
I generated client by help of Eclipse-web project from this service.
I have done searched on this service(live.net) but ı can't show on the console. How ı can do that?
public static void main(String[] args) throws RemoteException {
LiveSearchPortTypeProxy bb=new LiveSearchPortTypeProxy();
SearchRequest request=new SearchRequest();
SearchRequestType1 bbs=new SearchRequestType1();
aas.setParameters(request);
sorgu.setAppId("*****************************************"); //you can take this ID from live service for using this service
sorgu.setSources(new SourceType[]{SourceType.Web});
sorgu.setQuery("keyword");
SearchResponseType0 cevap= bb.search(bbs);
}

Have a look at the cevap variable and its public get methods in a debugger, and see what you have.
You will most likely end up with an instance of org.w3c.Node which represents the root of the parsed response. This can then be treated like any other DOM tree.

Related

Twilio using Gather to get UserID and Password

Currently, I'm testing out features of Twilio. I simply wanted to get two numbers from the user representing a username and password. What happens is because I don’t know what address to put in action, it defaults to the same time and loops the first gather over and over again. Currently, I’m using Spark and ngrok to test my code.
package com.example;
import com.twilio.twiml.VoiceResponse;
import com.twilio.twiml.voice.Gather;
import com.twilio.twiml.voice.Say;
import static spark.Spark.*;
public class Example {
public static void main(String[] args) {
post("/", (request, response) -> {
Say say = new Say.Builder(
"Enter UserID.")
.build();
Gather gather = new Gather.Builder().action("/").say(say).build();
Say say2 = new Say.Builder(
"Enter Password.")
.build();
Gather gather2 = new Gather.Builder().action("/").say(say2).build();
VoiceResponse voiceResponse = new VoiceResponse.Builder()
.gather(gather)
.gather(gather2)
.build();
return voiceResponse.toXml();
});
}
}
I tried changing the action attribute to a random address like /test, I changed the method to POST or GET, but neither seemed to have any effect except in the ngrok dashboard. The problem I'm currently having is I have no clue how to use Spark and the Gather verb together.
It repeats the actions over and over again because of the properties of the gather TwiMl element.
First, you should point to a different endpoint of your application and handle the response at this endpoint. Once you parse the user input at this endpoint, you can return another TwiML response that asks for the second input, which you then need to process at a third endpoint.
With this in mind, I see a second problem with the code above. You ask for both inputs sequentially, meaning you only ask for the second input if the caller ignores the first prompt and remains quiet. Look at "Scenario 1-3" of this page for more details.
I understand that implementing so many endpoints for a simple IVR might be confusing at first. The good news is that this can be much simpler by using Studio.

solrj Error from server invalid number

I'm trying to write some data from my java application to solr using solrj.
I can query the solr server fine, but whenever I try to write some data to the server I get an error of invalid number, even when I'm writing a string to a string field.
Sample code to reproduce the error:
public class solrdocimport {
public static void main(String[] args) throws MalformedURLException, SolrServerException, IOException {
SolrClient client = new HttpSolrClient("http://192.168.175.136:8983/solr/nsf");
SolrInputDocument solrDoc = new SolrInputDocument();
solrDoc.addField("Subject", "Hello", 1.0f);
client.add(solrDoc);
}
}
The field "Subject" exists in the schema and it is defined as a String field, however the error I get is invalid number?
I've search around an cannot find anything in relation to this error. Does anyone know how to I can write to the solr server?
Sounds you might have some automatic ID generation in solrconfig.xml and then you changed your id field in schema.xml to be a number. Try changing id back to string, since you are not using it and see if the problem goes away.

Translating using Google Translate API

I want to use the following code as the basis for a program that translates user input to English. I am getting the error "cannot find symbol - GoogleApi." Can someone please help me figure out what to do?
import com.google.api.translate.Language;
import com.google.api.translate.Translate;
public class Main {
public static void main(String[] args) throws Exception {
// Set the HTTP referrer to your website address.
GoogleAPI.setHttpReferrer(/* Enter the URL of your site here */);
// Set the Google Translate API key
// See: http://code.google.com/apis/language/translate/v2/getting_started.html
GoogleAPI.setKey(/* Enter your API key here */);
String translatedText = Translate.DEFAULT.execute("Bonjour le monde", Language.FRENCH, Language.ENGLISH);
System.out.println(translatedText);
}
}
what is exactly GoogleApi?
You have not declared that, in order to use it .. I did not understand the program fully, I suggest that you search the website or through google for a program to do that task, there are plenty.
A working code can be found here. It also has link to full codebase on github.
Things to keep in mind:
If you are behind proxy you need make jvm aware of this. One way of doing it is through a static initializer as below:
static
{
System.setProperty("http.proxyHost", HTTP_PROXY_HOST);
System.setProperty("http.proxyPort", HTTP_PROXY_PORT);
System.setProperty("https.proxyHost", HTTPS_PROXY_HOST);
System.setProperty("https.proxyPort", HTTPS_PROXY_PORT);
}
In Run configuration make your GOOGLE_API_KEY available by making it environment variable as below:
For setting up of API key Check section titled "Setting up an API Key".

what does here_now(String args0) in Pubnub do?

I am trying to find the clients subscribed to a particulair channel. On git I found an example which used a function here_now() with 2 parameters. Something like this:
pubnub.hereNow(channel, new Callback() {
public void successCallback(String channel,Object message) {
notifyUser("HERE NOW : " + message);
}
public void errorCallback(String channel,
Object message) {
notifyUser("HERE NOW : " + message);
}
});
But in my company's application the here_now() function takes only one parameter i.e a String. I am relatively new to pubnub. Can anyone explain me what this parameter is? is it a channel name? how do I specify the call back functions? I am not able to find any documentation related to here_now(String arg)
Thanks
Please run the PubNubDemoConsole.java... you can walk through how all the API calls work.
Specifically, for here_now():
https://github.com/pubnub/java/blob/master/java/examples/src/com/pubnub/examples/PubnubDemoConsole.java#L157
(Looks a lot like above :)
You are indeed passing it two arguments. The first is the channel name you want stats for, the second parameter is the callback function to deliver the success or error results on.
Be sure you are on the latest PubNub for Java version as well:
https://github.com/pubnub/java/blob/master/java
If there are additional questions, let us know here, or via support at pubnub.com
geremy

Messaging between Java and Flex with Flerry

I'm currently working on a project that need to communicate with java from air without the use of a server like Tomcat. For this i found and use Flerry.
Communicating between Java and Air is no problem, as long as I try to send a message from the class that I initially instantiated from Air.
What I try to do is subscript to messages from a Message Class in java and use that class to send info and errors to Air from Java.
MessageController.java:
public class MessageController
{
public MessageController()
{
}
public static void sendErrorMessage(String errorMessage)
{
NativeObject.sendMessage(errorMessage, "error");
}
public static void sendInfoMessage(String infoMessage)
{
NativeObject.sendMessage(infoMessage, "info");
}
}
In Air I create a NativeObject on the messaging class and subscribe to the messages:
var messageController:NativeObject = new NativeObject();
messageController.source = "controller.MessageController" ;
messageController.singleton = true;
messageController.debug = false;
messageController.addEventListener(FaultEvent.FAULT, onFileControllerFault, false, 0, true);
messageController.subscribe("info", infoMessageHandler);
messageController.subscribe("error", errorMessageHandler);
As you would have guessed, this doesn't work.
It seems that I am only able to dispatch messages from the class that I subscribe to directly, for example if I do this:
messageController.start();
and in my MessageController.java i put this:
public void start()
{
NativeObject.sendMessage("test message", "info");
}
the infoMessageHandler receives an message containing test message, as it should.
How can I dispatch messages from whatever class in Java and catch them on the Air side?
I'm not sure I fully understand the issue yet, but is there a reason you can't simply send and receive all messages through a Java 'communication' class? If that's working, I'd just set up public methods in Java interfacing/communications class and be done with it.
(It's been awhile since I've dug into how Flerry works so I can't recall enough to point out the likely cause of the behavior you're seeing.) Also Flerry is open source, and not very big at all. If you really want to know why it's behaving in a certain way, I'd wager you could figure it out by looking at the source. (Won't take 6 months to learn like some Spring or Hibernate code base, or even BlazeDS, I promise.)
I do use Flerry in a small app, but now that I think about it, I only have one class which dispatches anything to Flex! But I feel like you may need to describe the problem you're facing differently, because it sounds like expected behavior to me.

Categories

Resources