LibraryLink ToToggle FramesPrintFeedback

Implementing the Consumer's Business Logic

Once you instantiate a service proxy for a remote endpoint, you can invoke its methods as if it were a local object. The calls block until the remote method completes.


If a method is annotated with the @OneWay annotation, the call returns immediately.

Example 2.7 shows a consumer for the service defined in Example 1.7.

Example 2.7. Consumer Implemented without a WSDL Contract

package com.fusesource.demo;

import javax.xml.namespace.QName;

public class Client
public static void main(String args[])
    QName serviceName = new QName("", "stockQuoteReporter");
1  Service s = Service.create(serviceName);

    QName portName = new QName("", "stockQuoteReporterPort");
2  s.addPort(portName, "", "http://localhost:9000/EricStockQuote");

3  quoteReporter proxy = s.getPort(portName, quoteReporter.class);

4  Quote quote = proxy.getQuote("ALPHA");
    System.out.println("Stock "+quote.getID()+" is worth "+quote.getVal()+" as of "+quote.getTime());

The code in Example 2.7 does the following:


Creates a Service object.


Adds an endpoint definition to the Service object.


Gets a service proxy from the Service object.


Invokes an operation on the service proxy.