25.5. 소비자의 비즈니스 로직 구현

25.5.1. 개요

원격 끝점의 서비스 프록시를 인스턴스화하면 해당 메서드를 로컬 오브젝트인 것처럼 호출할 수 있습니다. 원격 메서드가 완료될 때까지 호출 블록입니다.

참고

메서드에 @OneWay 주석이 추가되면 호출이 즉시 반환됩니다.

25.5.2. 예제

예 25.7. “WSDL 계약 없이 고객 구현” 예 24.7. “완전히 주석 처리 SEI” 에 정의된 서비스의 소비자를 표시합니다.

예 25.7. WSDL 계약 없이 고객 구현

package com.fusesource.demo;

import java.io.File;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;

public class Client
{
public static void main(String args[])
  {
    QName serviceName = new QName("http://demo.eric.org", "stockQuoteReporter");
  Service s = Service.create(serviceName);

    QName portName = new QName("http://demo.eric.org", "stockQuoteReporterPort");
  s.addPort(portName, "http://schemas.xmlsoap.org/soap/", "http://localhost:9000/EricStockQuote");

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

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

예 25.7. “WSDL 계약 없이 고객 구현” 의 코드는 다음을 수행합니다.

Service 오브젝트를 생성합니다.

Service 오브젝트에 끝점 정의를 추가합니다.

Service 오브젝트에서 서비스 프록시를 가져옵니다.

서비스 프록시에서 작업을 호출합니다.