참조

1. Services Client-side Code 생성
- build.xml
  : Ant Build 하기 전에 Web Service Server 를 실행시켜야 함.
<project default="wsimport">

  <target name="wsimport">
    
    <exec executable="wsimport">    
      <arg line="-keep -s ./src -p com.hoon.webclient.service
          -d ./bin http://localhost:8080/hello?wsdl"/>
    </exec>
  
   <exec executable="wsimport">    
      <arg line="-keep -s ./src -p com.hoon.webclient.service
          -d ./bin http://localhost:8080/login?wsdl"/>
    </exec>
  
  </target>

</project>

- Ant Build 실행하면 코드 생성됨 (com.hoon.webclient.service)


2. Client Application 생성

LoginClient.java
package com.hoon.webclient.login;

import javax.xml.ws.BindingProvider;

import com.hoon.webclient.service.SampleLogin;
import com.hoon.webclient.service.SampleLoginService;

public class LoginClient {

public static void main(String args[]) {
 
        SampleLoginService shs = new SampleLoginService();
 
        SampleLogin sh = (SampleLogin) shs.getSampleLoginPort();
 
        ((BindingProvider)sh).getRequestContext().put(BindingProvider.
            ENDPOINT_ADDRESS_PROPERTY, "http://localhost:8080/login");

        System.out.println( ((BindingProvider)sh).toString() );

        System.out.println(sh.checkLogin("bbaeggar", "000"));
굵게
    }
}

SayHelloClient.java
package com.hoon.webclient.hello;

import javax.xml.ws.BindingProvider;

import com.hoon.webclient.service.SayHello;
import com.hoon.webclient.service.SayHelloService;

public class SayHelloClient {

 public static void main(String args[]) {
 
        SayHelloService shs = new SayHelloService();
 
        SayHello sh = (SayHello) shs.getSayHelloPort();
 
        ((BindingProvider)sh).getRequestContext().put(BindingProvider.
            ENDPOINT_ADDRESS_PROPERTY, "http://localhost:8080/hello");

        System.out.println( ((BindingProvider)sh).toString() );

        System.out.println(sh.getGreeting("bbaeggar"));
    }
}


3. Run

Posted by 짱가쟁이