[SOAP 모니터링 사용]


TCP Monitor(윈도APP)

D:/work>java org.apache.axis.utils.tcpmon

위와 같이 하면 자바 위도APP가 실행되는데, 여기서 로컬포트를 지정하는 곳이 있다.

일종의 터널링이라 할 수 있는데, 클라이언트가 이 포트를 통해 요청하면 프락시 역활을 하여 서버에 요청하고 그 결과를 다시 클라이언트에 전송한다.

이 과정에서 TCP Monitor는 클라이언트/서버간 주고 받는 메시지를 파악하게 되는 것이다.

사용자가 할 일은 기존 클라이언트가 서비스를 제공받기 위해 접속하던 주소를 변경해주면 된다.

즉, 아래와 같이 해주면 된다.


//public final static String ENDPOINT = http://127.0.0.1:8080/FOO/services/MyService;

:원래 접속할 서버

public final static String ENDPONT = "http://127.0.0.1:1234/FOO/services/MyService;

:TCP Monitor용 연결


처음 실행 화면, 여기서 리스터 포트는 1234로 설정하고 추가 버튼을 클릭한다.

사용자 삽입 이미지
 

로컬의 1234포트로 클라이언트의 연결을 기다리고 있다.

사용자 삽입 이미지


클라이언트가 접속한 예.

사용자 삽입 이미지


[SOAP Monitor(애플릿)]

http://localhost:8080/axis/SOAPMonitor


[SOAP Monitor 활성화하기]

활성화하리 위해 2과정이 필요하다


1. SOAPMonitorApplet.java 애플릿 컴파일

2. deploy-monitor.wsdd를 통한 SOAP Monitor deploy


1.SOAPMonitorApplet.java 애플릿 컴파일

E:/>type d:/util/axis.bat

@echo off

set AXIS_HOME=D:util.axis-1_4

set AXIS_LIB=%AXIS_HOME%/lib

set AXISCLASSPATH=%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

set CLASSPATH=%CLASSPATH%;%AXISCLASSPATH%

E:/>axis.bat

E:/>cd "%CATALINA_HOME%/webapps/axis"

E:/>Program Files/Apache Software Foundation/Tomcat 5.5/webapps/axis>javac SOAPMonitorApplet.java

Note : SOAPMonitorApplet.java.uses or overrides a deprecated API.

Note : Recompile with -Xlint : deprecation for details.

Note : SOAPMonitorApplet.java uses unchecked or unsafe operations.

Note : Recompile with -Xlint : unchecked for details.


2. deploy-monitor.wsdd를 통한 SOAP Monitor deploy

D:/work>java org.apache.axis.client.AdminClient deploy-monitor.wsdd

log4j:WARN No appenders coulde be found for logger(org.apache.axis.i18n.ProjectResourceBundle).

log4j:WARN Please initialize the log4j system property.

Processing file deploy-monitor.wsdd

<Admin>Done processing</Admin>


[deploy-monitor.wsdd]

<deployment xmlns=http://xml.apache.org/axis/wsdd/

                   xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">

    <handler name="soapmonitor"

                 type="java:org.apache.axis.handlers.SOAPMonitorHandler">

        <parameter name="wsdlURL"

                         value="/aixs/SOAPMonitorService-impl.wsdl" />

        <parameter name="namespace"

                         value=http://tempuri.org/wsdl/2001/12/SOAPMonitorService-impl.wsdl />

        <parameter name="serviceName" value="SOAPMonitorService" />

        <parameter name="portName" value="Demo" />

    </handler>

    <service name="SOAPMonitorService" provider="java:RPC">

        <parameter name="allowedMethods" value="publishMessage" />

        <parameter name="className" value="org.apache.axis.monitor.SOAPMonitorService" />

        <parameter name="scope" value="Application" />

    </service>

</deployment>


[브라우저에서 SOAP 모니터를 실행]

사용자 삽입 이미지


[SOAP Monitor 사용예]

deploy.wsdd작성시 requestFlow, responseFlow를 추가해주면 해당 웹서비스가 주고받는 SOAP메시지를 실시간으로 볼 수 있다.

개발과정에서 아주 요긴하게 사용될 수 있다.

2회때 사용한 예제에서 deploy.wsdd파일에 다음을 추가해주기만 하면된다.

[deploy,wsdd]

<deployment 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="*">

        <requestFlow><handler type="soapmonitor" /></requestFlow>

        <responseFlow><handler type="soapmonitor" /></responseFlow>

    </service>

</deployment>


D:/work>java Client "안녕, 세상아!"

log4j:WARN No appenders coulde be found for logger(org.apache.axis.i18n.ProjectResourceBundle).

log4j:WARN Please initialize the log4j system property.

You typed : 안녕, 세상아!

D:work>


브라우저에 모니터링된 SOAP,메시지는 그림과 같다.

 

사용자 삽입 이미지
Posted by 나비:D
:

[메시지 스타일 서비스]

자바코드로의 매핑을 빼고 XML데이터 자체를 주고받는 서비스다.


D:/work>type MessageService.java

import org.w3c.dom.Element;

import javax.xml.soap.*;

public class MessageService{

    public Element[] echoElements(Element[] elems){

        return elems;

    }

    public void Process(SOAPEnvelope req, SOAPEnvelope res) throws javax.xml.soap.SOAPException{

        SOAPBody body = res.getBody();

        Name ns0 = res.createName("TestNS0", "ns0", http://aa.com);

        Name ns1 = res.createName("TestNS1", "ns1", http://aa.com);

        SOAPElement bodyElement = body.addBodyElement(ns0);

        SOAPElement el = bodyElement.addChildElement(ns1);

        el.addTextNode("TEST RESPONSE");

    }

}

D:/work>javac MessageService.java

D:/work>copy MessageService.class "%CATALINA_HOME%/webapps/axis/WEB-INF/classes"

1개 파일이 복사되었습니다.

D:/work>type deploy.wsdd

<deployment name="test" xmlns=http://xml.apache.org/axis/wsdd/

                   xmlns:java=http://xml.apache.org/axis/wsdd/providers/java

                   xmlns:xsi="http://www.w3c.org/2000/10/XMLSchema-instance">

//주석 : note that either style="message" OR provider="java:MSG" both work

    <service name="MessageService" style="message">

        <parameter name="className" value="MessageService" />

        <parameter name="allowedMethods" value="echoElements" />

    </service>

    <service name="MessageService2" style="message">

        <parameter name="className" value="MessageService" />

        <parameter name="allowedMethods" value="process" />

    </service>

</deployment>

D:/work>type undeploy.wsdd

<undeploytment name="test" xmlns="http://xml.apache.org/axis/wsdd/">

    <service name="MessageService" />

</undeployment>

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

D:/work>jaba org.apache.axis.client.AdminClient list

log4j : WARN No appenders could be 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=http://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="attachments.Directory" value="E:/Program Files/Apache Software Foundation.Tomcat5.5/webapps/axis/WEB-INF/arrachments" />

        <ns1:parameter name="dotNetSoapEncFix" value="true" />

        <ns1:parameter name="enableNamespacePrefixOptimization" value="false" />

        <ns1:parameter name="sendXsiTypes" value="true" />

        <ns1:parameter name="attachments.implementation" value="org.apache.axis.attachments.AttachmentsImpl" />

        <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.SimpleAuthenticationHAndler" />

    <ns1:service name="MessageService2" provider="java:MSG" style="message" use="literal">

        <ns1:parameter name="allowedMethods" value="process" />

        <ns1:parameter name="className" value="MessageService" />

        <ns1:parameter name="sendXsiTypes" value="false" />

        <ns1:parameter name="sendMultiRefs" value="false" />

    </ns1:service>

    <ns1:service name="MessageService" provider="java:MSG" style="message" use="literal">

        <ns1:parameter name="allowedMethods" value="echoElements" />

        <ns1:parameter name="className" value="MessageService" />

        <ns1:parameter name="sendXsiTypes" value="false" />

        <ns1:parameter name="sendMultiRefs" value="false" />

    </ns1:service>

    <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.utils.Admin" />

        <ns1:namespace>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: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.QSWSDLHandler" />

        <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.QSWSDLHandler" />

    </ns1:transport>

    <ns1:transport name="local">

        <ns1:responseFlow>

            <ns1:handler type="LocalResponder" />

        </ns1:responseFlow>

    </ns1:transport>

</ns1:deployment>


[클라이언트로 서비스 테스트]

D:/work>javac TestMsg.java

D:/work>java TestMsg

log4j : WARN No appenders could be found for logger(org.apache.axis.i18n.ProjectResourceBundle).

log4j : WARN Please initialize the log4j system property.

D:/work>type TestMsg.java


import org.apache.axis.client.Call;

import org.apache.axis.client.Service;

import org.apache.axis.message.SOAPBodyElement;

import org.apache.axis.utils.Options;

import org.apache.axis.Utils.XMLUtils;

import org.w3c.dom.CDATASection;

import org.w3c.dom.Document;

import org.w3c.dom.Element;

import javax.xml.parsers.DocumentBuilder;

import javax.xml.parsers.DocumentBuilderFactory;

import javax.xml.soap.MessageFactory;

import javax.xml.soap.MimeHeaders;

import javax.xml.soap.SOAPConnection;

import javax.xml.soap.SOAPConnectionFactory;

import javax.xml.soap.SOAPEnvelope;

import javax.xml.soap.SOAPMessage;

import javax.xml.soap.SOAPPart;

import java.io.ByteArrayInputStream;

import java.net.URL;

import java.util.Vector;


//주석 : Simple test driver for our message service.


public class TestMsg{

    public String doit(String[] args) throws Exception{

        Optionsopts = new Options(args);

        opts.setDefaultURL(http://localhost:8080/axis/service/MessageService);

        Service service = new Service();

        Call call = (Call) service.createCall();

        call.setTargetEndpointAddress(new URL(opts.getURL()));

        SOAPBodyElement[] input = new SOAPBodyElement[3];

        input[0] = new SOAPBodyElement(XMLUtils.,StringToElement("urn:foo", "e1", "Hello"));

        input[1] = new SOAPBodyElement(XMLUtils.,StringToElement("urn:foo", "e1", "World"));

        DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocunebtBuilder();

        Document doc = builder.newDocument();

        Element cdataElem = doc.createElementNS("urn:foo", "e3");

        CDATASection cdata = doc.createCDATASection("Text with/n/t Important <b> witespace</b> and tags!");

        cdataElem.appendChild(cdata);

        input[2] = new SOAPBodyElement(cdataElem);

        Vector elems = (Cevtor)call.invoke(input);

        SOAPBodyElement elem = null;

        Element e = null;

        elem = (SOAPBodyElement) elems.get(0);

        e = elem.getAsDOM();

        String srt = "Reselem[0]=" + XMLUtils.ElementToString(e);

        elem = (SOAPBodyElement) elems.get(1);

        e = elem.getAsDOM();

        str = str + "Reselem[1]=" + XMLUtils.ElementToString(e);

        elem = (SOAPBodyElement) elems.get(2);

        e = elem.getAsDOM();

        str = str + "Reselem[2]=" + XMLUtils.ElementToString(e);

        return(str);

    }

    public void testEnvelope(String[] args) throws Exception{

        String xmlString =

         "<?xml version=/"1.0/" encoding=/"UTF-8/"?>/n"+

         "<soapenv:Envelope xmlns:soapenv=/"http://schemas.xmlsoap.org/soap/envelope//"/n+

         "xmlns:xsd=/"http://www.w3.org/2001/XMLSchema/"/n"+

         "xmlns:xsi=/"http://www.w3.org/2001/XMLSchema-instance/">/n"+

         "<soapenv:Header>/n"+

         "<shw:Hello xmlns:shw=/"http://localhost:8080/axis/services/MessageService/">/n"+

         "<shw:Myname>Tony</shw:Myname>/n"+

         "</shw:Hello>/n"+

         "</soapenv:Header>/n"+

         "<soapenv:Body>/n"+

         "<shw:process xmlns:shw=/"http://message.samples/">/n"+
         "<shw:City>GENT</shw:City>/n"+
         "</shw:process>/n" +
         "</soapenv:Body>/n"+
         "</soapenv:Envelope>/n"+
         MessageFactory mf = MessageFactory.newInstance();
         SOAPMessage smsg =
mf.createMessage(new MimeHeaders(), new ByteArrayInputStream(xmlString.getBytes()));
         SOAPPart sp = smsg.getSOAPPart();
         SOAPEnvelope se = (SOAPEnvelope)sp.getEnvelope();
         SOAPConnection conn = SOAPConnectionFactory.newInstance().createConnection();        
         SOAPMessage response = conn.call(smsg, http://localhost:8080/axis/services/MessageService2);
    }
    public static void main(String[] args) throws Exception{
        TestMsg testMsg = new TestMsg();
        testMsg.doit(args);
        testMsg.testEnvelope(args);
    }
}

Posted by 나비:D
:

[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>

Posted by 나비:D
:

AXIS 설치

1. Axis압축파일(axis-bin-1_4.zip)를 다운받아 압축파일내에 있는 webapps/axis 폴더를 %CATALINA_HOME%/webapps에 푼다

2. 톰캣을 실행하고 브라우저에서 http://localhost:8080/axis/주소로 연결되면 성공


[Trouble Shooting]

위의 주소로 연결후 CAll이라고 되어 있는 링크를 클릭하면 아래와 같은 에러가 발생할 수 있다.

Call -Call a local endpoint that list's the caller's http headers

에러 : java.lang.RuntimeException: No compiler found in your classpath!(you may need to add 'tools.jar')


이는 톰캣 설치시 사용할 런타임 JRE 위치를 JDK가 아닌 JRE로 했기 때문입니다.

이럴 경우 톰캣을 다시 설치하여 JDK쪽의 경로로 변경해주면 된다. 그럴 수 없다면 JDK의 tool.jar를 %CATALINA_HOME%/common/lib로 복사해주면 된다.


JAVA_HOME은 E:/Program Files/Java/jdk1.5.0_09/lib/tool.jar

D:/work>copy "%JAVA_HOME%/lib/tools.jar" "%CATALINA_HOME%/common/lib"

1개 파일이 복사되었습니다.


Administer Axis, SOAPMonitor는 디폴트로 사용할 수 없게 되어 있으므로 지금은 무시한다.

Administer Axis는 web.xml에서 해당 부분을 주석해제하면 사용할 수 있고, SOAPMonitor는 4부에서 설명하겠다.


 [부가기능 설치]

3. JavaMail(javamail-1_4.zip)을 다운받아 압축파일내 mail.jar를 CLASSPATH에 등록

http://java.sun.com/products/javamail/downloads/index.html

4. ㅓㅁㅍ므먀ㅣsms ㅓㅁㄹ vozlwl(jaf-1_1-fr.zip)를 필요로 하므로 이 또한 설치(activation.jar)

http://java.sun.com/beans/glasgow/jaf.html

* 즉, mail.jar와 activation.jar를 %CATALINA_HOME%/common.lib에 넣어주면 된다.


[웹서비스 작성과 테스트(서버측)]

소스파일의 확장자를 jws로 변경하여 올리면 알아서 웹서비스를 수행한다.

jws확장자를 가지면 AXIS는 이 파일이 SOAP기능을 수행할 수 있게 자동으로 모든 과정을 처리해준다.

간편하게 테스트용으로 사용할 수 있겠으나 내부적으로 어떻게 돌아가는지 파악이 되지 않으므로 이런자동구성보다는 수동으로 제어(WSDD파일을 이용)하는 것이 바람직할 것이다.


D:work>type Calculator.java

public class Calculator{

    public int add(int a, int b){

        return a+b;

    }

    public int subtract(int a, int b){

        return a-b;

    }

}


D:work>copy Calculator.java "%CATALINA_HOME%webappsaxisCalculator.jws"

1개 파일이 복사되었습니다.


* .jws 확장자를 가지면 웹서비스로 인식하게끔 web.xml에 설정되어 있다.

위처럼 작업한 뒤, 브라우저에서 http://localhost:8080/axis/Calculator.jws로 접속하면 아래와 같다.


[브라우저 접속화면]

위처럼 확장자를 jws로 만들어 deploy하며느 AXIS는 자동으로 웹서비스가 제공될 수 있도록 처리해준다.

사용자 삽입 이미지


WSDL도 자동으로 만들어 주므로 편하다.


사용자 삽입 이미지


[콘솔에서 테스트 클라이언트(클라이언트측)]

D:work> type CalcClient.java


import org.apache.axis.client.Call;

import org.apache.axis.client.Service;

import org.apache.axis.encording.XMLType;

import org.apache.axis.utils.Options;

import javax.xml.rpc.ParameterMode;

public class CalcClient{

    public static void main(String[] args) throws Exception{

        Options options = new Options(args);

        String endpoint = http://localhost: + options.getPort() + "/axis/Calculator.jws";

        args = options.getRemainingArgs();

        if ( args == null || args.length != 3){

            System.err.println("Usage: CalcClient <add|subtract> arg1 arg2");

            return;

        }

        String method = args[0];

        if ( !(method.equals("add") || method.equals("subtract"))){

            System.err.println("Usage: CalcClient <add|subtract> arg1 arg2");

            return;

        }

        Integer i1 = new Integer(args[1]);

        Integer i2 = new Integer(args[2]);

        Service service = new Service();

        Call Call = (Call) service.createCall();

        call.setTargetEndpointAddress( new java.net.URL(endpoint));

        call.setOperationName(method);

        call.addParameter("op1", XMLType.XSD_INT, ParameterMode.IN);

        call.addParameter("op2", XMLType.XSD_INT, ParameterMode.IN);

        call.setReturnType(XMLType.XSD_INT);

        Integer ret = (Integer) call.invoke(new Object [] {i1, i2});

        System.out.println("Got result : " + ret);

    }

}


D:/work>set AXIS_HOME=D:/util/axis-1_4

D:/work>set AXIS_LIB=%AXIS_HOME%/lib

D:/work>set AXISCLASSPATH=%AXIS_LIB%/axis.jar;%AXIS_LIB%/jaxrpc.jar;%AXIS_LIB%/saaj.jar;%AXIS_LIB%/log4j-1.2.8.jar;%AXIS_LIB%/common-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 CalcClient.java

D:/work>java CalcClient add 1 2

log4j:WARN No appenders could be found for logger (org.apache.axis.i18n.ProjectResourceBundle).

log4k:WARN please initialize the log4j system. properly.

Got result : 3

D:work>java CalcClient subtract 3 1

log4j:WARN No appenders could be found for logger(org.apache.axis.i18n.ProjectResourceBundle).

log4j:WARN Please initialize the log4j system property.

Got result : 2


D:/work>

Posted by 나비:D
:

BLOG main image
by 나비:D

공지사항

카테고리

분류 전체보기 (278)
Programming? (0)
---------------------------.. (0)
나비의삽질 (5)
Application (177)
SQL (51)
Web (27)
XML (9)
CSS (0)
JSP (8)
JAVASCRIPT (2)
ASP (1)
HTML (0)
WebService-Axis (4)
etc. (14)
Omnia (0)
---------------------------.. (0)

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

글 보관함

달력

«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Total :
Today : Yesterday :