[WSDD를 이용한 웹서비스 개발]
D:work>type MyService.java
public class MyService{
public String serviceMEthod(String arg){
return arg;
}
}
D:/work>type deploy.wsdd
<deplyment xmlns=http://xml.apache.org/axis/wsdd/ xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="MyService" provider="java:RPC">
<parameter name="className" value="MyService"/>
<parameter name="allowMethods" value="*"/>
</service>
</deployment>
D:work>type undeploy.wsdd
<undeployment xmlns="htt://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<service name="MyService" />
</undeployment>
[톰캣 시동후, 자것ㅇ한 웹서비스를 deploy]
D:/work>set AXIS_HOME=D:util/axis-1_4
D:/work>set AXIS_LIB=%AXIS_HOME%/lib
D:/work>setAXISCLASSPATH=%AXIS_LIB%/axis.jar;%AXIS_LIB%/jaxrpc.jar;%AXIS_LIB%/saaj.jar;%AXIS_LIB%/log4j-1.2.8.jar;%AXIS_LIB%/commons-discovery-0.2.jar;%AXIS_LIB%/commons-logging-1.0.4.jar;%AXIS_LIB%/wsdl4j-1.5.1.jar
D:/work>set CLASSPATH=%CLASSPATH%;%AXISCLASSPATH%
D:/work>javac MyService.java
D:/work>copy MyService.class "%CATALINA_HOME%/webapps/axis/WEB-INF.classes"
1개 파일이 복사되었습니다.
AdminClient를 이용해 웹서비스를 deploy
D:/work>java org.apache.axis.client.AdminClient deploy.wsdd
log4j:WARN No appenders could ve found for logger(org.apache.axis.i18n.ProjectResourceBundle).
log4j:WARN Please initialize the log4j system property.
Processing file deploy.wsdd
<Admin>Done processing</Admin>
D:/wrok>
*undeploy하려면 다음과 같다.
D:/work>java org.apache.axis.client.AdminClient undeploy.wsdd
log4j:WARN No appenders could be found for logger(org.apache.axis.i18n.ProjectResourceBundle).
log4j:WARN please initialize the log4j system property.
Processing file undeploy.wsdd
<Admin>Done processing<Admin>
[클라이언트 접속 테스트]
D:/work>type Client.java
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import org.apache.axis.utile.Options;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
public class Client{
public static void main(String[] args){
try{
Options options = new Options(args);
String endpointURL = http://localhost:8080/axis/services/MyService;
String textToSend;
args = options.getRemainingArgs();
if((args == null) || (args.length < 1)){
textToSend = "<nothing>";
}else{
textToSend = args[0];
}
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpointURL));
call.setOperationName(new QName("ServiceMethod"));
call.addParameter("arg1", XMLType.XSD_STRING, ParameterMode.IN);
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
String ret = (String) call.invoke(new Object[] {textTosend} );
System.out.println("You typed : " +ret);
} catch(Exception e){
System.err.println(e.toString());
}
}
}
D:/wrok>javac Client.java
D:/work>java Client "안녕, 세상아!"
log4j:WARN No appenders could be found for logger(org.apache.axis.i18n.projectResourceBundle).
log4j:WARN Please initialize the log4j system property.
You typed : 안녕, 세상아!
* 웹서비스 deploy되었는지 확인하려면 AdminClient의 list 명령을 사용하면 된다.
이 명령으로 출력된 결과는 AXIS의 설정파일인 WEB-INF/server-config.xml의 내용이다.
이 파일은 명시적으로 생성하지 않으면 axis가 시작할 때 자동으로 만들게 된다.
D:/work>java org.apache.axis.client.AdminClient list
D:/work>java org.apache.axis.client.AdminClient deploy.wsdd
log4j:WARN No appenders could be found for logger(org.apache.axis.i18n.ProjectResourceBundle).
log4j:WARN Please initialize the log4j system property.
Processing file deploy.wsdd
<Admin>Done processing</Admin>
D:/work>java org.apache.axis.client.AdminClient list
log4j:WARN No appenders could ve found for logger(org.apache.axis.i18n.ProjectResourceBundle).
log4j:WARN Please initialize the log4j system property.
<ns1:deployment xmlns="http://xml.apache.org/axis.wsdd/" xmlns:java="htt://xml.apache.org/axis/wsdd/providers/java" xmlns:ns1="http://xml.apache.org/axis/wsdd/">
<ns1:globalConfiguration>
<ns1:parameter name="sendMultiRefs" value="true" />
<ns1:parameter name="disablePrettyXML" value="true" />
<ns1:parameter name="adminPassword" value="admin" />
<ns1:parameter name="attachements.Directory" value="E:/Program Files/Apache Software Foundation.Tomcat 5.5/webapps/axis/WEB-INF/attachements" />
<ns1:parameter name="dotNetSoapEncFix" value="true" />
<ns1:parameter name="enableNamespacePrefixOptimization" value="false" />
<ns1:parameter name="sendXMLDeclaration" value="true" />
<ns1:parameter name="sendMultiRefs" value="true" />
<ns1:parameter name="disablePrettyXML" value="true" />
<ns1:parameter name="arrachments.implementation" value="org.apache.axis.attachments.ArrachmentsImpl" />
<ns1:parameter name="sendXsiTypes" value="true" />
<ns1:requestFlow>
<ns1:handler type="java:org.apache.axis.handlers.JWSHandler">
<ns1:parameter name="scope" value="session" />
</ns1:handler>
<ns1:handler type="java:org.apache.axis.handlers.JWSHandler">
<ns1:parameter name="scope" value="request" />
<ns1:parameter name="extension" value=".jwr" />
</ns1:handler>
</ns1:requestFlow>
</ns1:globalConfiguration>
<ns1:handler name="LocalResponder" type="java:org.apache.axis.transport.local.LocalResponder" />
<ns1:handler name="URLMapper" type="java:org.apache.axis.handlers.http.URLMapper" />
<ns1:handler name="Authenticate" type="java:org.apache.axis.handlers.SimploAuthenticationHandler" />
<ns1:service name="AdminService" provider="java:MSG">
<ns1:parameter name="allowedMethods" value="AdminService" />
<ns1:parameter name="enableRemoteAdmin value="false" />
<ns1:parameter name="className" value="org.apache.axis.utiles.Admin"/>
<ns1:namesapce>http://xml.apache.org/axis/wsdd/</ns1:namespace>
</ns1:service>
<ns1:service name="Version" provider="java:RPC">
<ns1:parameter name="allowedMEthods" value="getVersion" />
<ns1:parameter name="className" value="org.apache.axis.Version" />
</ns1:service>
<ns1:service name="MyService" provider="java:RPC">
<ns1:parameter name="className" value="MyService" />
<ns1:parameter name="allowMethods" value="*"/>
</ns1:service>
<ns1:transport name="http">
<ns1:requestFlow>
<ns1:handler type="URLMapper" />
<ns1:handler type="java:org.apache.axis.handlers.http.HTTPAuthHandler" />
</ns1:requestFlow>
<ns1:parameter name="qs:list" value="org.apache.axis.transport.http.QSListHandler" />
<ns1:parameter name="qs:wsdl" value="org.apache.axis.transport.http.SQWSDLHandler" />
<ns1:parameter name="qs:list" value="org.apache.axis.transport.http.QSListHandler" />
<ns1:parameter name="qs:method" value="org.apache.axis.transport.http.QSMethodHandler" />
<ns1:parameter name="qs:method" value="org.apache.axis.transport.http.QSMethodHandler" />
<ns1:parameter name="qs:wsdl" value="org.apache.axis.transport.http.SQWSDLHandler" />
</ns1:transport>
<ns1:transport name="local">
<ns1:responseFlow>
<ns1:handler type="LocalREsponder" />
</ns1:responseFlow>
</ns1:reansport>
</ns1:deployment>
D:/work>
D:/work>java org.apache.axis.client.AdminClient undeploy.wsdd
log4j:WARN No appenders could be found for logger(org.apache.axis.i18n.ProjectResourceBundle).
log4j:WARN Please initialize the log4j system property.
Processing file undeployt.wsdd
<Admin>Done processing</Admin>
D:/work>java Client "안녕, 세상아!"
log4j:WARN No appenders could be found for logger(org.apache.axis.i18n.ProjectResourceBundle).
log4j:WARN Please initialize the log4j system.property.
The AXIS engine could not find a target service to invoke! targetService is MyService
D:/work>
[출처] AXIS 설치 & 사용법 2/4|작성자 희열