SeouliteLab

이클립스에서 웹서비스 만들기 본문

프로그래밍

이클립스에서 웹서비스 만들기

Seoulite Lab 2018. 12. 29. 17:23

[Eclipse 웹서비스 기본 설정]


1. Axis2 다운로드

http://axis.apache.org/axis2/java/core/download.cgi



2. Window - Preferences - Web Services - Axis2 Preferences

    axis2 runtime location 폴더경로 설정

    C:\axis2-1.7.9

    이상없다면, Axis2 runtime loaded successfully 메세지 확인


3. Window - Preferences - Web Services - Server and Runtime

아래와 같이 설정

Server runtime : Tomcat v6.0 Server

Web service runtime : Apache Axis2



[Web Service 생성]

1. Dynamic Web Project 생성


(Tomcat6.0, dynamic web version 2.5)


2. Project Facets : Axis2 Web Service 모두 체크 후 저장


3. jstl-1.2.jar, xmlschema-core-2.2.1.jar 라이브러리 추가 ( Service Webcontent/WEB-INF/lib 폴더 )


4. java 파일 생성

public class Hello {
    public String getHello(String msg){
        return msg + " WS";
    }
}



5. Web service 생성


    생성한 javaFile우클릭 > Web Services > Create Web Services

    - Server runtime : Tomcat v6.0

    - Web service runtime : Apache Axis2

6. 아래와 같이 messageReceivers 변경


    /프로젝트명/WebContent/WEB-INF/services/Hello/META-INF/services.xml 


#기존#



	
		Please Type your service description here
	
	
		
		
	
	dev.Hello


#변경#


	
		Please Type your service description here
	
	
		
		
	
	dev.Hello



  NoClassDefFoundError 관련 오류 발생시  Service Webcontent/WEB-INF/lib 폴더에 axis2-1.7.4\lib\xmlschema-core-2.2.1.jar 추가


7. http://localhost:8080/WebServiceTest/services/Hello?wsdl 호출하여 정상적으로 출력여부 확인



[Web Service Client 생성]


1. Dynamic Web Project 생성

(Tomcat6.0, dynamic web version 2.5)


2. Project Facets : Axis2 Web Service 모두 체크 후 저장


3. Web Service Client 생성


    - Service Definition : 상단에서 생성한 웹서비스 url

        (http://localhost:8080/WebServiceTest/services/Hello?wsdl)

Configuration

    - Server runtime : Tomcat6.0

    - Web service runtime: Apache Axis2

- Client project : 현재 프로젝트 선택


Next > 로 이동후

    - Generate all types for all elements referred to by schemas 체크


   NoClassDefFoundError : NamespacePrefixList 관련 오류 발생시 : 해당 Service Webcontent/WEB-INF/lib 폴더에 axis2-1.7.4\lib\xmlschema-core-2.2.1.jar 추가


4. 생성된 Stub 확인


5. 로직 테스트.


public class MainClass {
	public static void main(String[] args) {		
		try {
			HelloStub stb = new HelloStub();
			HelloStub.GetHello request = new HelloStub.GetHello();
			String msg = "\"This is a test message.\"";
			request.setMsg(msg);
			HelloStub.GetHelloResponse res = stb.getHello(request);
			System.out.println(res.get_return());			
		}catch(Exception e) {
			System.out.println(e.getMessage());
		}
	}
}


6. 출력결과 : "This is a test message." WS



참조 사이트

http://ddulh.tistory.com/284

http://egloos.zum.com/js7309/v/10644853

http://egloos.zum.com/entireboy/v/4342149

http://blog.naver.com/ixoixo/120054662617