2010. 6. 29. 17:59
참조
1. Services Client-side Code 생성
- build.xml
: Ant Build 하기 전에 Web Service Server 를 실행시켜야 함.
- Ant Build 실행하면 코드 생성됨 (com.hoon.webclient.service)
2. Client Application 생성
LoginClient.java
SayHelloClient.java
3. Run
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>
<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"));
굵게
}
}
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"));
}
}
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
'java > web' 카테고리의 다른 글
[HttpClient] - GetMethod 사용하자 (0) | 2010.06.30 |
---|---|
[web service] - ServletWebServer 사용기.. (0) | 2010.06.30 |
[web service] - XmlRpcServlet 을 사용하기. (0) | 2010.06.30 |
[web service] - apache-xmlrpc-3.1.2 사용기.. (0) | 2010.06.30 |
[web] - SOAP vs XML-RPC (0) | 2010.06.30 |