简体   繁体   中英

WSDL Web Service for desktop application

I am working on a desktop application, where the user inputs a word, then its definition is displayed. For this I am using the web service: DictService. My code runs fine, the only problem i have is that it does not return the definition.

Here is my code:

the "jTextField1" is where the user writes the word.

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    String str = jTextField1.getText();
    System.out.println(define(str));
}        

The method define is:

private static WordDefinition define(java.lang.String word) {
    com.aonaware.services.webservices.DictService service = new com.aonaware.services.webservices.DictService();
    com.aonaware.services.webservices.DictServiceSoap port = service.getDictServiceSoap();
    return port.define(word);
}

For example, when i enter the word "test", the output is: "com.aonaware.services.webservices.WordDefinition@f48725b"

I really do not know how to fix this, any help would be greatly appreciated. Thank you.

EDIT:

The method outputs a list of definitions, whereas i output only a string. So i have created a list to store all definitions. And i iterated it to output them.

Here is the code to create the list and output it:

 String str = jTextField1.getText();

    List<WordDefinition> definitions = new ArrayList<WordDefinition>(Arrays.asList(define(str)));
    for (int i=0; i< definitions.size(); i++){
        System.out.println(Arrays.deepToString(definitions.get(i))); //i get an error here
    }

Now the error i get is: "incompatible types: WordDefinition cannot be converted to Object[]"

How can i fix that?

The class WordDefinition obviously does not have a nice toString() method. You have to explicitely access a member of the returned value:

System.out.println(define(str).getSomeValue());

Since I do not know the internals of your framework I cannot give more advice.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM