주소록 - 구성 및 실행


샘플 구성
샘플 실행

두 개의 주소록 클라이언트, J2SE(Java 2 Standard Edition) 버전과 J2EE(Java 2 Enterprise Edition) 컨테이너 관리 버전이 있습니다. J2EE 컨테이너 서비스의 이점을 완전히 활용하려면 J2EE 버전을 실행하십시오.

샘플 구성

이 샘플의 구성을 완료하려면 서버에서 JAX-RPC 웹 서비스 샘플 응용프로그램을 전개하십시오. 샘플 응용프로그램이 아직 전개되지 않은 경우, WebServicesSamples.ear 파일 다시 빌드 및 전개에 대한 지시사항을 참조하십시오.

샘플 실행

클라이언트를 실행하기 전에 서버가 시작되었는지 확인하십시오.

두 개의 주소록 클라이언트, J2SE 외부 버전과 J2EE(Java 2 Enterprise Edition) 컨테이너 관리 버전이 있습니다. 각 클라이언트는 서버에 구현된 주소록 웹 서비스 Bean의 네 가지 변형을 실행합니다. 주소록 웹 서비스 Bean은 고정 값을 리턴하며 인터넷 연결 실행을 필요로 하지 않습니다.

J2SE 단순 주소록 클라이언트 실행
J2EE 응용프로그램 주소록 클라이언트 실행

J2SE 단순 주소록 클라이언트 실행

J2SE 주소록 클라이언트는 웹 서비스 주소록 Bean을 조회하여 웹 서비스에서 주소를 가져오는 과정을 보여줍니다. profile_root/samples/src/WebServicesSamples/Clients/simpleClients/samples/address 디렉토리에서 해당 소스를 찾을 수 있습니다.

AddressBookClient를 실행할 경우, AddressBook.wsdl 파일은 현재 디렉토리에 있어야 합니다. simpleClients.jar 파일에서 AddressBook.wsdl 파일의 압축을 해제한 후 샘플을 실행하려는 디렉토리에 넣으십시오. install_root/samples/lib/WebServicesSamples 디렉토리에서 simpleClients.jar 파일을 찾을 수 있습니다.

J2SE 클라이언트는 서버에 구현된 각 주소록 웹 서비스 Bean을 두 번 루프합니다. 첫 번째 루프 중 클라이언트는 getPort 메소드를 호출하여 샘플 응용프로그램의 각 Bean에 대해 고유한 포트를 확보합니다. 클라이언트는 각 포트에서 getAddressFromName 메소드를 호출합니다. 두 번째 루프는 임의로 포트 중 하나로 시작한 후 루프하면서 엔드포인트 주소를 네 개의 가능한 엔드포인트로 각각 설정합니다. 클라이언트는 각 포트에서 getAddressFromName 메소드를 호출합니다.

J2SE WebSphere 클라이언트 호출에 관한 일반 지시사항은 InfoCenter에 있는 thin 응용프로그램 클라이언트 코드 전개 관련 항목을 참조하십시오.

WebSphere Application Server에서 J2SE 단순 주소록 클라이언트를 실행하려면 운영 체제에 따라 다음 단계를 수행하십시오.

  1. 서버를 시작하십시오.
  2. 명령 프롬프트를 여십시오.
  3. 다음 명령을 발행하십시오.

    Windows 플랫폼:

    cd profile_root\bin
    setupCmdLine
    cd install_root\bin
    setupCmdLine

    Linux, UNIX 및 z/OS 플랫폼:

    cd profile_root/bin
    . ./setupCmdLine.sh
    cd install_root/bin
    . ./setupCmdLine.sh

    iSeries 플랫폼:

    cd profile_root/bin
    . ./setupCmdLine
    cd install_root/bin
    . ./setupCmdLine

  4. AddressBook.wsdl 파일을 포함하는 디렉토리로 변경하십시오.
  5. 다음 명령을 실행하십시오.

    Windows 플랫폼:

    "%JAVA_HOME%\bin\java" %WAS_LOGGING% -classpath "%WAS_CLASSPATH%;%WAS_HOME%\samples\lib\WebServicesSamples\simpleClients.jar;%WAS_HOME%\runtimes\com.ibm.ws.webservices.thinclient_7.0.0.jar" samples.address.AddressBookClient [<host_name> <port_number>]

    Linux, UNIX 및 z/OS 플랫폼:

    "$JAVA_HOME/bin/java" $WAS_LOGGING -classpath "$CLASSPATH:$WAS_CLASSPATH:$WAS_HOME/samples/lib/WebServicesSamples/simpleClients.jar:$WAS_HOME/runtimes/com.ibm.ws.webservices.thinclient_7.0.0.jar" samples.address.AddressBookClient [<host_name> <port_number>]

    iSeries 플랫폼:

    java $JAVA_PARM -classpath "$CLASSPATH:$WAS_CLASSPATH:$WAS_HOME/samples/lib/WebServicesSamples/simpleClients.jar:$WAS_HOME/runtimes/com.ibm.ws.webservices.thinclient_7.0.0.jar" samples.address.AddressBookClient [<host_name> <port_number>]

    여기서
    <host_name> 은 서비스 엔드포인트 주소의 호스트 이름입니다. 기본 호스트 이름은 localhost입니다.
    <port_number> 는 서비스 엔드포인트 주소의 포트 번호입니다. 기본 포트 번호는 9080입니다.

    다음은 주소록 클라이언트가 성공적으로 실행된 예제를 나타냅니다.

    
    C:\>"%JAVA_HOME%\bin\java" %WAS_LOGGING% -classpath "%WAS_CLASSPATH%;%WAS_HOME%\samples\lib\WebServicesSamples\simpleClients.jar;%WAS_HOME%\runtimes\com.ibm.ws.webservices.thinclient_7.0.0.jar" samples.address.AddressBookClient
    >> Querying address for 'Purdue Boilermaker' using port AddressBookW2JE
    >> Response is:
    	1 University Drive
    	West Lafayette, IN 47907
    	Phone: (765) 555-4900
    >> Querying address for 'Purdue Boilermaker' using port AddressBookJ2WE
    >> Response is:
    	2 University Drive
    	West Lafayette, IN 47907
    	Phone: (765) 555-4900
    >> Querying address for 'Purdue Boilermaker' using port AddressBookJ2WB
    >> Response is:
    	3 University Drive
    	West Lafayette, IN 47907
    	Phone: (765) 555-4900
    >> Querying address for 'Purdue Boilermaker' using port AddressBookW2JB
    >> Response is:
    	4 University Drive
    	West Lafayette, IN 47907
    	Phone: (765) 555-4900
    >>
    >> Get port AddressBookJ2WB
    >> Set port AddressBookJ2WB's endpoint to http://localhost:9080/AddressBookW2JE/services/AddressBook
    >> Querying address for 'Purdue Boilermaker'
    >> Response is:
    	1 University Drive
    	West Lafayette, IN 47907
    	Phone: (765) 555-4900
    >> Set port AddressBookJ2WB's endpoint to http://localhost:9080/AddressBookJ2WE/services/AddressBook
    >> Querying address for 'Purdue Boilermaker'
    >> Response is:
    	2 University Drive
    	West Lafayette, IN 47907
    	Phone: (765) 555-4900
    >> Set port AddressBookJ2WB's endpoint to http://localhost:9080/AddressBookJ2WB/services/AddressBook
    >> Querying address for 'Purdue Boilermaker'
    >> Response is:
    	3 University Drive
    	West Lafayette, IN 47907
    	Phone: (765) 555-4900
    >> Set port AddressBookJ2WB's endpoint to http://localhost:9080/AddressBookW2JB/services/AddressBook
    >> Querying address for 'Purdue Boilermaker'
    >> Response is:
    	4 University Drive
    	West Lafayette, IN 47907
    	Phone: (765) 555-4900
    
    

J2EE 응용프로그램 주소록 클라이언트 실행

J2EE 응용프로그램 주소록 클라이언트는 J2SE 단순 주소록 클라이언트와 비슷합니다. 이 클라이언트는 동일한 AddressBook Web Service Bean에 액세스하지만 launchClient 명령을 사용하여 J2EE 응용프로그램 클라이언트 컨테이너에서 액세스합니다.

J2EE 클라이언트는 서버에 구현된 각 주소록 웹 서비스 Bean을 루프합니다. 이 클라이언트는 JNDI(Java Naming and Directory Interface) lookup 명령을 사용하여 주소록 서비스를 찾고 포트 호출 가져오기를 수행하여 네 개의 주소록 Bean 각각에 대해 고유한 포트를 확보합니다. 클라이언트는 각 포트에서 getAddressFromName 메소드를 호출합니다.

다음 단계에서 install_root 변수는 WebSphere 설치 루트를 나타냅니다.

WebSphere Application Server에서 J2EE 응용프로그램 주소록 클라이언트를 실행하려면, 운영 체제에 따라 다음 단계를 수행하십시오.

  1. 서버를 시작하십시오.
  2. 명령 프롬프트를 여십시오.
  3. 다음 명령을 입력하십시오.

    Windows 플랫폼:

    cd <profile_root>\bin
    setupCmdLine

    Linux, UNIX 및 z/OS 플랫폼:

    cd <profile_root>/bin
    . ./setupCmdLine.sh

    iSeries 플랫폼:

    cd <profile_root>/bin
    . ./setupCmdLine

    여기서 <profile_root>는 프로파일 설치 디렉토리를 나타냅니다.
  4. install_root/samples/lib/WebServicesSamples 디렉토리로 변경하십시오.
    여기서
    install_root는 WebSphere Application Server 설치 루트이거나, 샘플이 다시 빌드된 경우에는 프로파일 설치 루트입니다.
  5. install_root를 WebSphere 설치 루트로 바꾼 후 다음 명령을 발행하십시오.

    Windows 플랫폼:

    install_root\bin\launchClient ApplicationClients.ear -CCjar=AddressBookClient.jar [<host_name> <port_number>]

    Linux, UNIX 및 z/OS 플랫폼:

    install_root/bin/launchClient.sh ApplicationClients.ear -CCjar=AddressBookClient.jar [<host_name> <port_number>]

    iSeries 플랫폼:

    install_root/bin/launchClient ApplicationClients.ear -CCjar=AddressBookClient.jar [<host_name> <port_number>]

    여기서
    <host_name> 은 서비스 엔드포인트 주소의 호스트 이름입니다. 기본 호스트 이름은 localhost입니다.
    <port_number> 는 서비스 엔드포인트 주소의 포트 번호입니다. 기본 포트 번호는 9080입니다.


    다음은 주소록 클라이언트가 성공적으로 실행된 예제를 나타냅니다.

    
    C:\WebSphere\AppServer\samples>\WebSphere\AppServer\bin\launchClient \WebSphere\AppServer\samples\lib\WebServicesSamples\ApplicationClients.ear -CCjar=AddressBookClient.jar
    IBM WebSphere Application Server, Release 7.0
    J2EE Application Client Tool
    Copyright IBM Corp., 1997-2008
    WSCL0012I: Processing command line arguments.
    WSCL0013I: Initializing the J2EE Application Client Environment.
    [3/29/06 14:47:51:062 CST] 0000000a  W UOW=null source=com.ibm.ws.ssl.config.SSLConfig org=IBM prod=WebSphere component=Application Server thread=[P=269328:O=0:CT]
              CWPKI0041W: One or more key stores are using the default password.
    WSCL0035I: Initialization of the J2EE Application Client Environment has completed.
    WSCL0014I: Invoking the Application Client class com.ibm.websphere.samples.webservices.addr.AddressBookClient
    >> Querying address for 'Purdue Boilermaker' using port AddressBookW2JE
    >> Response is:
    	1 University Drive
    	West Lafayette, IN 47907
    	Phone: (765) 555-4900
    >> Querying address for 'Purdue Boilermaker' using port AddressBookJ2WE
    >> Response is:
    	2 University Drive
    	West Lafayette, IN 47907
    	Phone: (765) 555-4900
    >> Querying address for 'Purdue Boilermaker' using port AddressBookJ2WB
    >> Response is:
    	3 University Drive
    	West Lafayette, IN 47907
    	Phone: (765) 555-4900
    >> Querying address for 'Purdue Boilermaker' using port AddressBookW2JB
    >> Response is:
    	4 University Drive
    	West Lafayette, IN 47907
    	Phone: (765) 555-4900
    
    

주소록 기술 노트를 참조하여 Java 소스 코드를 보면 클라이언트 및 응용프로그램의 작동 방법을 더 자세히 알 수 있습니다.