본문 바로가기

웹서비스

예제 HotelHilton - 파일있다

웹서비스 등록(수정이나 기타 변경)후,

tomcat 반드시 재시작할것!!

1279263617_soap_with_attachments_tutorial.tar.gz <-- 아래것보다 좋다. 서버쪽 소스안에 path는 자신에 맞게 재설정.

1279263617_HotelHilton.tar.gz <-- 파일이 없어 전부 수작업으로 만들고 실행확인했다. 안되면환경문제임.

예제는 HotelHilton 서비를 만들고, 클라이언트로 HotelHiltonClient를 만든다.

1.XML은 아래와 같다.

1-1. 클라이언트가 보낸 XML 파일 포맷

<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<ns1:getAvailableRoom xmlns:ns1="http://statdb.stat2.smba.go.kr">
<ns1:city>pusan</ns1:city>
</ns1:getAvailableRoom>
</soapenv:Body>
</soapenv:Envelope>

1-2. 서버가 결과로 보낸 XML 파일
<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<ns:getAvailableRoomResponse xmlns:ns="http://statdb.stat2.smba.go.kr">
<ns:return>9</ns:return>
</ns:getAvailableRoomResponse>
</soapenv:Body>
</soapenv:Envelope>

2. 이제 부터 만들어 보자.

2.1 AXIS 2 설치 한다.

2.2 tomcat에 연동한다.

2.3 컴파일 할수 있도록 환경 변수에 CLASSPATH에 lib안의 jar를 몽땅 걸어준다.

2.4 ant 를 설치 한다.(별거 없다. 이넘은 make 와 같은 일을 하는넘이다.)

/etc/profile 에 추가

-----------------------------------------------------------------------------

export CATALINA_HOME="/usr/local/apache-tomcat-6.0.28"
export JAVA_HOME="/usr/java/default"
export AXIS2_HOME="/usr/local/axis2-1.5.1"
export ANT_HOME="/usr/local/ant-1.8.1"

#export AXIS2_LIB=$CATALINA_HOME/webapps/axis2/WEB-INF/lib
export AXIS2_LIB=$AXIS2_HOME/lib

AXIS2CLASSPATH=$AXIS2_LIB/XmlSchema-1.4.3.jar:$AXIS2_LIB/axis2-json-1.5.1.jar:$AXIS2_LIB/geronimo-annotation_1.0_spec-1.1.jar:$AXIS2_LIB/mex-1.5.1.jar:$AXIS2_LIB/activation-1.1.jar:$AXIS2_LIB/axis2-kernel-1.5.1.jar:$AXIS2_LIB/geronimo-jaxws_2.1_spec-1.0.jar:$AXIS2_LIB/neethi-2.0.4.jar:$AXIS2_LIB/axiom-api-1.2.8.jar:$AXIS2_LIB/axis2-metadata-1.5.1.jar:$AXIS2_LIB/geronimo-saaj_1.3_spec-1.0.1.jar:$AXIS2_LIB/smack-3.0.4.jar:$AXIS2_LIB/axiom-dom-1.2.8.jar:$AXIS2_LIB/axis2-mtompolicy-1.5.1.jar:$AXIS2_LIB/geronimo-stax-api_1.0_spec-1.0.1.jar:$AXIS2_LIB/smackx-3.0.4.jar:$AXIS2_LIB/axiom-impl-1.2.8.jar:$AXIS2_LIB/axis2-saaj-1.5.1.jar:$AXIS2_LIB/geronimo-ws-metadata_2.0_spec-1.1.2.jar:$AXIS2_LIB/soapmonitor-1.5.1.jar:$AXIS2_LIB/axis2-adb-1.5.1.jar:$AXIS2_LIB/axis2-spring-1.5.1.jar:$AXIS2_LIB/httpcore-4.0.jar:$AXIS2_LIB/woden-api-1.0M8.jar:$AXIS2_LIB/axis2-adb-codegen-1.5.1.jar:$AXIS2_LIB/axis2-transport-http-1.5.1.jar:$AXIS2_LIB/jalopy-1.5rc3.jar:$AXIS2_LIB/woden-impl-dom-1.0M8.jar:$AXIS2_LIB/axis2-ant-plugin-1.5.1.jar:$AXIS2_LIB/axis2-transport-local-1.5.1.jar:$AXIS2_LIB/jaxb-api-2.1.jar:$AXIS2_LIB/wsdl4j-1.6.2.jar:$AXIS2_LIB/axis2-clustering-1.5.1.jar:$AXIS2_LIB/axis2-xmlbeans-1.5.1.jar:$AXIS2_LIB/jaxb-impl-2.1.7.jar:$AXIS2_LIB/wstx-asl-3.2.4.jar:$AXIS2_LIB/axis2-codegen-1.5.1.jar:$AXIS2_LIB/bcel-5.1.jar:$AXIS2_LIB/jaxb-xjc-2.1.7.jar:$AXIS2_LIB/xalan-2.7.0.jar:$AXIS2_LIB/axis2-corba-1.5.1.jar:$AXIS2_LIB/commons-codec-1.3.jar:$AXIS2_LIB/jaxen-1.1.1.jar:$AXIS2_LIB/xercesImpl-2.6.2.jar:$AXIS2_LIB/axis2-fastinfoset-1.5.1.jar:$AXIS2_LIB/commons-fileupload-1.2.jar:$AXIS2_LIB/jettison-1.0-RC2.jar:$AXIS2_LIB/xml-apis-1.3.02.jar:$AXIS2_LIB/axis2-java2wsdl-1.5.1.jar:$AXIS2_LIB/commons-httpclient-3.1.jar:$AXIS2_LIB/jibx-bind-1.2.1.jar:$AXIS2_LIB/xml-resolver-1.2.jar:$AXIS2_LIB/axis2-jaxbri-1.5.1.jar:$AXIS2_LIB/commons-io-1.4.jar:$AXIS2_LIB/jibx-run-1.2.1.jar:$AXIS2_LIB/xmlbeans-2.3.0.jar:$AXIS2_LIB/axis2-jaxws-1.5.1.jar:$AXIS2_LIB/commons-lang-2.3.jar:$AXIS2_LIB/log4j-1.2.15.jar:$AXIS2_LIB/axis2-jibx-1.5.1.jar:$AXIS2_LIB/commons-logging-1.1.1.jar:$AXIS2_LIB/mail-1.4.jar

#AXIS2CLASSPATH=


PATH=.:$JAVA_HOME/bin:$AXIS2_HOME/bin:$ANT_HOME/bin:$PATH:$HOME/bin
CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar:$CATALINA_HOME/lib/servlet-api.jar:$CATALINA_HOME/lib/catalina-ant.jar:$AXIS2CLASSPATH

#CLASSPATH=$CLASSPATH:/home/sang/client/src/kr/go/smba/stat2/statdb

---------------------------------------------------------------------------------

build.xml

---------------------------------------------------------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<project name="HotelHilton" basedir="." default="BuildAAR">
<property name="src.dir" value="src" />
<property name="aar.dir" value="aar" />
<property name="bin.dir" value="bin" />
<property name="deploy.dir" value="deploy" />
<property name="deploy.file" value="HotelHilton.aar" />
<target name="Structure" depends="" description="[AXIS2] structure for the AAR">
<mkdir dir="${aar.dir}" />
<mkdir dir="${aar.dir}/META-INF" />
<copy todir="${aar.dir}" preservelastmodified="true">
<fileset dir="${bin.dir}" includes="**/*.*" excludes="*.xml" />
</copy>
<copy todir="${aar.dir}/META-INF" preservelastmodified="true">
<fileset dir="${src.dir}" includes="services.xml" />
</copy>
</target>
<target name="BuildAAR" depends="Structure" description="[AXIS2] AAR">
<mkdir dir="${deploy.dir}" />
<jar destfile="${deploy.dir}/${deploy.file}">
<fileset dir="${aar.dir}">
<include name="**/*.*" />
</fileset>
</jar>
<copy todir="${deploy.path}" preservelastmodified="true">
<fileset dir=".">
<include name="*.aar" />
</fileset>
</copy>
<delete dir="${aar.dir}"/>
</target>
</project>

-------------------------------------------------------------------------------------

compile.xml

--------------------------------------------------------------------------------------

<project name="HotelHilton" basedir="." default="compile">
<property name="src.dir" value="src" />
<property name="bin.dir" value="bin" />
<target name="compile" depends="" description="Compiling the Web Service">
<delete dir="${bin.dir}" />
<mkdir dir="${bin.dir}" />
<javac debug="on" srcdir="${src.dir}" destdir="${bin.dir}" includeantruntime="false" />
</target>
</project>

---------------------------------------------------------------------------------------------

services.xml

---------------------------------------------------------------------------------------------

<service name="HotelHilton">
<description>HotelHilton</description>
<parameter name="ServiceClass">
kr.go.smba.stat2.statdb.HotelHilton
</parameter>
<operation name="getAvailableRoom">
<messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
</operation>
</service>

---------------------------------------------------------------------------------------------

HotelHilton.java

----------------------------------------------------------------------------------------------------

package kr.go.smba.stat2.statdb;

public class HotelHilton
{
public HotelHilton()
{

}

public int getAvailableRoom(String city)
{
return (int) ((Math.random() * 100) % 10);
}
}

----------------------------------------------------------------------------------------------------

쏘리...시간 날때,다음에 계속

'웹서비스' 카테고리의 다른 글

Apache Axis2 User`s Guide - 번역본링크  (0) 2010.07.16
AXIS2 예제 링크  (0) 2010.07.16
WEB Services 링크 -&gt; 잘 모아 놓았군요.  (0) 2010.07.16
XML Web Services 정리  (0) 2010.07.16
AXIS2에는 내장된 SOAPMonitor  (0) 2010.07.15