ÈËÉú¼Ü¹¹
来源: BlogBus 原始链接: http://www.blogbus.com:80/blogbus/blog/index.php?blogid=24566&m=20041010 存档链接: https://web.archive.org/web/20041124151924id_/http://www.blogbus.com:80/blogbus/blog/index.php?blogid=24566&m=20041010 作者: wuhaixing
ÈËÉú¼Ü¹¹ ÈËÉúÊÇÒ»¸öϵͳ£¬Ô½À´Ô½¶àµÄÈËչʾËûÃǵÄÉú»îÈçºÎÔËÐС£¶øÃ÷ÌìµÄÄãÈçºÎÔËת£¬Ö´ÐÐÕßÖ»ÄÜÊÇÄã×Ô¼º£¬ÃæÁÙµÄÎÞ·ÇÊÇÈÎÎñºÍÖ´ÐС£ ¹¹½¨Ò»¶ÎÈËÉúÐèÒª×÷³öºÜ¶àµÄÑ¡Ôñ£¬»ýÀÛ²»Í¬µÄ×é¼þ£¬È·¶¨Á¼ºÃµÄ½á¹¹ºÍ»úÖÆ£¬¾Àú²»Í¬½×¶ÎµÄʵÏÖ.... analysis,architecture,design,developer .: ÈÕÀú :. 2004 Äê 10 Ô Sun Mon Tue Wen Thu Fri Sat 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 .: ¿ìËٵǼ :. .: ×îºó¸üР:. ×é³ÉÓïÑÔµÄÈýÒªËØ ³õ·ÃZope ×Ô±àstudy guide Java Servlet & JSP Cookbook ×Ö·û´®´¦ÀíÖеÄÇ¿Á¦¹¤¾ß-regular expression ÌìÄÄ£¬»¨ÁËÕâô¶àʱ¼ä¿´Ð¡Ëµ£¡£¡£¡ ×òÌìÒÔ800ÔªµÄ¼Û¸ñÂòµ½ÁËvoucher ÓÖ·¢ÏÖÁËsunµÄÓŻݻ ʵÔÚ²»Ïë¸É»î£¬×öÁËÒ»ÉÏÎçIQÌâ (Öµ)ÀàÐ͵ÄʵÏÖ-flyweight Éè¼ÆÄ£Ê½ .:
×îÐÂÆÀÂÛ :.
×±×Ó
:
ÍêÈ«¿´²»¶®°¡.....
wuhaixing
:
ÀúÊ·¼Í¼£¬ÓÒ¼ü²ì.
pizz@!
:
¹ý²»È¥µÚ3¹Ø°¡ÎÒ.
pizz@!
:
Õâ¸öÕâ¸ö~ºÃÄѰ¡.
wuhaixing
:
»Ø¼ÒÊÔÁËһϣ¬·¢.
wuhaixing
:
½ñÌì¿´Á˶ÁÕ߲ŷ¢.
wuhaixing
:
ÐÀÎÅËûËùÔÚ¹«Ë¾ÒÑ.
wuhaixing
:
¿´ÁËǰÁ½Õ£¬¾õµÃ.
wuhaixing
:
°¥£¡»¹ÊÇÊäÁË£¬Ð¡.
.:
´æµµ :. 1970/01/02/-2004/07/28 2004/07/29/-2004/08/06 2004/08/07/-2004/08/21 2004/08/22/-2004/08/31 2004/10/02/-2004/11/05 2004/09/01/-2004/09/14 2004/09/15/-2004/10/01 .:
ÎÒµÄÁ´½Ó :. <<<<>>>> safari object mentor <<<<>>>> java˵Ã÷Êé sun¼¼ÊõÉçÇø martix - ×î¼Ñjava×ÊÔ´Õ¾ javaÊÓÏß-ÀÏÊÖÂÛ̳ javaRanch-greenhornFriend TheServerSide.com-Your Enterprise Java Community <<<>>> ¿ª·ÅÂÛ̳-xml Xmethods-publicly available web services list <<<<<<¹âÓ°´«Ëµ>>>>>> ¹âÓ°Ö®Ô´£bt every day ×ÊÁÏ¿â£mov6 ÒôÀÖÎÞÏÞ£music 001 <<<<>>>> LinuxForums.Org iptables£°²È«µÚÒ» chinapub£¼¼ÊõÖмá <<<ÐÔÄÜÒ²·è¿ñ>>> java pt <<<¹¤³ÌºÜ¹Ø¼ü>>> QCA£ÖÊÁ¿¡¢³É±¾¡¢Ãô½Ý <<<<>>>> Martin Fowler Daves Roller <<<<<Web...>>>>> W3Schools-Full Web Building Tutorials .:
À©Õ¹¹¦ÄÜ :. :: Ê×Ò³ ʵս¾Ñé (43) ÈÏÖ¤Àú³Ì (35) ¹âÓ°´«Ëµ (7) ÏÐÇÃÆå×Ó (23) linux Xray (6) ²»ÖªËù´ë (2) ÀíÂÛ»ù´¡ (7) AxisϵÁÐ-userGuide-WSDD details
- [ʵս¾Ñé] 1.Review Axis Components&Server side Architecture 1.1 Axis Components • Deployment/Configuration ¨C deployment refers to component registrations • services, handlers, chains, transports,bean mappings and type mappings (register serializers and deserializers) ¨C configuration refers to setting Axis options • such as security controls for remote administration ¨C Administration subsystem provides the easiest way to do this • pass WSDD file to AdminClient • Handlers ¨C operate on request and response messages • can examine a message and modify it before passing it on ¨C can invoke software outside Axis ¨C example uses • authentication, compression, encryption, logging, message transformation • Chains ¨C collections of handlers that are executed in a specified order ¨C a chain is itself handler, allowing chains to contain other chains • Provider (a.k.a. ¡° pivot point¡± handler) ¨C point in the chain where handlers switch from processing the request to processing the response ¨C invokes web service operation • Transports ¨C handle message protocol conversions • request from client to Axis Engine (for example, HTTPTransport) • response from Axis Engine to client • Serializers/Deserializers ¨C convert Java data (primitives and objects) to and from XML • Axis engines ¨C coordinate message processing by invoking a series of handlers ¨C run on server and optionally on client 1.2 Axis server side Architecture • configured by server-config.wsdd in webapps/axis/WEB-INF which is modified by AdminClient • actually there is a single transport chain that is considered to have two sides • an Axis"service"is a"targeted chain"(can have request handlers, a pivot handler and response handlers) 2.WSDD DTD Highlights&Overall sample server-config.wsdd 2.1 WSDD DTD(attributes omitted)
2.2 Overall sample server-config.wsdd • View elements in webapps/axis/WEB-INF/server-config.wsdd < globalConfiguration
< handler name =" handlername " type =" java:full class name " /> list < service name =" service name " provider =" java:[RPC|MSG] "> list < transport name =" http|local ">list < requestFlow
& < responseFlow
in global and transport < parameter name =" name " value =" value " /> 3.Configuring service with WSDD • A service is a targeted chain , which means it may have any/all of ¨Ca request flow, ¨Ca pivot Handler (which for a service is called a " provider "), ¨Ca response flow. • "java:RPC" provider(typical value) deployment ¨C"java:RPC" provider is built into Axis, and indicates a Java RPC service. ¨CThe actual class which handles this is org.apache.axis.providers.java.RPCProvider . ¨CWe need to : • tell the RPCProvider that it should instantiate and call the correct class£¬we do so by including tags, giving the service one parameter to configure the class name, • tell the engine that any public method on that class may be called via SOAP (that's what the "*" means; we could also have restricted the SOAP-accessible methods by using a space or comma separated list of available method names). • Learn other Service Styles (Document, Wrapped, and Message provider) pls refer to http://ws.apache.org/axis/java/user-guide.html • Scoped Services ¨CAxis supports scoping service objects (the actual Java objects which implement your methods) three ways. • "Request" scope, the default, will create a new object each time a SOAP request comes in for your service. • "Application" scope will create a singleton shared object to service all requests. • "Session" scope will create a new object for each session-enabled client who accesses your service. ¨CTo specify the scope option, you add a to your service like this (where "value" is request, session, or application): <service name="MyService"...> < parameter name=" scope " value="value" /> ... 4.Configuring Handlers With WSDD 4.1 handler overview • Three kinds of handler elements ¨C unnamed - ¨C named - • can be used in multiple chain/phases ¨C reference to named - • Handlers are only added to chains through deployment ¨C not dynamically at run-time • Three chains ¨C transport, global and service • Two phases ¨C request and response 4.2 Three chains handler configuring • Global handlers < globalConfiguration
< requestFlow
handler-element* < /requestFlow
< responseFlow
handler-element* < /responseFlow
< / globalConfiguration
• Transport-specific handlers < transport name =" http "> < requestFlow
handler-element* < /requestFlow
< responseFlow
handler-element* < /responseFlow
< / transport
• Service-specific handlers < service name =" service-name " provider =" java:RPC "> < requestFlow
handler-element* < /requestFlow
< responseFlow
handler-element* < /responseFlow
< / service
4.3 Example-deploy a service-specific handler:LogHandler • extends org.apache.axis.handlers.BasicHandler to implements Log logic package com.building.handlers; import org.apache.axis.AxisFault; import org.apache.axis. Handler ; import org.apache.axis.MessageContext; import org.apache.axis.handlers.BasicHandler; import java.io. FileOutputStream ; import java.io. PrintWriter ; import java.util. Date ; import org.apache.axis.transport.http.HTTPConstants; import javax.servlet.http.HttpServletRequest; public class LogHandler extends BasicHandler { public void invoke(MessageContext msgContext) throws AxisFault { /** Log an access each time we get invoked. / try { Handler serviceHandler = msgContext.getService(); //get filename in deploy.wsdd configuration of handler String filename = ( String )getOption( "logFile" ); if ((filename == null ) || (filename.equals( "" ))) throw new AxisFault( "Server.NoLogFile" , "No log file configured for the LogHandler!" , null , null ); /* create FileOutputStream in append mode / FileOutputStream fos = new FileOutputStream (filename, true ); PrintWriter writer = new PrintWriter (fos); //get accesses times in serviceHandler Integer numAccesses = ( Integer )serviceHandler.getOption( "accesses" ); if (numAccesses == null ) numAccesses = new Integer (0); /* populates log info */ numAccesses = new Integer (numAccesses.intValue() + 1); Date date = new Date (); String result = getRemoteHost(getRequest(msgContext)) + "@"
- date + ": service "
- msgContext.getTargetService() + " accessed "
- numAccesses + " time(s)" ; //set accesses times in serviceHandler serviceHandler.setOption( "accesses" , numAccesses); //write log info into logFile and close fos writer.println(result); writer.close(); } catch ( Exception e) { throw AxisFault.makeFault(e); } } /** Helper method for getRemoteHost Address from HttpServletRequest; / private String getRemoteHost(HttpServletRequest request) { HttpServletRequest request = getRequest(msgContext); String remote = "NOT-HTTP-Transport" ; if (request != null ) remote=request.getRemoteHost(); return remote; } /* Helper method for get HttpServletRequest from MessageContext; */ private HttpServletRequest getRequest(MessageContext msgContext) { if (msgContext != null ) { HttpServletRequest req = (HttpServletRequest) msgContext.getProperty( HTTPConstants.MC_HTTP_SERVLETREQUEST); return req; } return null ; } } • deploy handler in deploy.wsdd < handler name =" track " type =" java:com.building.handlers.LogHandler ">
< parameter name =" logFile " value =" ./log/CaculatorLog.txt " /> </ handler
............ < service name =" Caculator " provider =" java:RPC "> < requestFlow
< handler type =" track " /> < /requestFlow
............ < / service
............ • deploy handler class into webapps/axis/WEB-INF/classes and redploy Caculator service • invoke Caculator service and check $CATALIAN_HOME/logs/ to check Log file. 5.Register a Java Bean For Automatic Serialization • beanMapping is needed if a object is passed to or returned from a web service operation • appropriate when the class follows Java Bean conventions and all of its properties should be serialized • beanMapping Example
< deployment xmlns =" http://xml.apache.org/axis/wsdd/ " xmlns:java =" http://xml.apache.org/axis/wsdd/providers/java "
< service name =" CarQuote " provider =" java:RPC "
< parameter name =" className " value =" com.ociweb.cardealer.CarQuoteImpl " /> < parameter name =" allowedMethods " value =" getQuote " /> </ service
< beanMapping xmlns:ns =" urn:CarQuote " qname =" ns:Car " languageSpecificType =" java:com.ociweb.cardealer.Car " /> </ deployment
6.Custom Type Mapping ¨C write serializer class • implements org.apache.axis.encoding.Serializer ¨C write serializer factory class that returns serializer instances • implements org.apache.axis.encoding.SerializerFactory ¨C write deserializer class • extends org.apache.axis.encoding.DeserializerImpl ¨C write deserializer factory class that returns deserializer instances • implements org.apache.axis.encoding.DeserializerFactory ¨C register them using WSDD and the Admin client ¨C Example typeMapping < typeMapping xmlns:ns =" urn:CarQuote " qname =" ns:Car " type =" java:com.ociweb.cardealer.Car " serializer =" com.ociweb.cardealer.CarSerializerFactory " deserializer =" com.ociweb.cardealer.CarDeserializerFactory " encodingStyle =" http://schemas.xmlsoap.org/soap/encoding/ " /> wuhaixing ·¢±íÓÚ 2004-10-10 -- 17 : 46 : 30 | ÔĶÁÈ«ÎÄ | ÆÀÂÛ(0) | ÒýÓÃ(trackback0) | ±à¼ AxisϵÁÐ-userGuide-Publishing Web Services
- [ʵս¾Ñé] 1 Instant Deployment - JWS (Java Web Service) Files 1.1 Steps ¨C if not there already,copy ¡°axis¡± directory in ¡°webapps¡± directory of the Axis distribution to the deployment directory of a server that supports Java servlets • for Tomcat, this is the ¡°webapps¡± directory ¨C copy any Java source file that implements a web service into this ¡° axis¡± directory • no special code is required • all public, non-static methods are exposed • if the class is in a package, copy it to the appropriate subdirectory ¨C change the file extension from ¡° .java¡± to ¡° .jws¡± ¨C to view the WSDL of a JWS web service,enter the following URL in a web browser http://host:port/axis/ pkg-subdirs /file-name.jws?wsdl 1.2 jws deployment example • Source file Caculator.java package com.building.math; public class Caculator { public int add( int n1, int n2) { return n1 + n2; } public int subtract( int n1, int n2) { return n1 - n2; } } • Steps to deploy this ¨C create com/building/math directories under axis directory in Tomcat¡¯s webapps directory ¨C copy Caculator.java to that directory ¨C rename it to Caculator.jws • Access the WSDL with ¨C http://localhost:8080/axis/ com/building/math /Caculator.jws?wsdl( wrong address ) ¨C can generate client stubs using WSDL2Java and this URL • Invoking the service for test
- client source (Dynamic Invocation) import javax.xml.namespace.QName; import org.apache.axis.client.Call; import org.apache.axis.client.Service; public class CaculatorClient { public static void main(String[] args) { try { Service service = new Service(); Call call = (Call) service.createCall(); call.setTargetEndpointAddress(new java.net.URL("http://localhost:8081/axis/Caculator.jws")); call.setOperationName(new QName("Caculator","add")); System.out.println(call.invoke(new Object[] {new Integer(1),new Integer(2)})+""); }catch(Exception exp) { exp.printStackTrace(); } } } -execute tcpmon:java org.apache.axis.utils.tcpmon 8081 localhost 80 -execute client:java CaculatorClient -result is "3" printed! ×¢Òâ:Èçaxis¹Ù·½µÄuserguideËùÑÔ£¬Ê¹ÓÃpackageµÄʱºò»á³öһЩÎÊÌâ¡£ Important: JWS web services are intended for simple web services. You cannot use packages in the pages, and as the code is compiled at run time you can not find out about errors until after deployment. Production quality web services should use Java classes with custom deployment. µ«Õâ¿ÉÄÜÊÇÒ»¸öÉÐδ½â¾öµÄbug.ʹÓÃÉÏÃæµÄÀý×Ó£¬²¿ÊðÖ®ºó·ÃÎÊjws£¬¿ÉÒÔ¿´µ½Õý³£µÄÌáʾ£¬µ«Èç¹û·ÃÎÊ*.jws?wsdl£¬Ôò»áÌáʾÎÞ·¨ÕÒµ½ÀàÎļþ¡£ÔÚWEB-INF/jwsClassesÏÂÃæ¿ÉÒÔ¿´µ½Ò»¸öÐÂÉú³ÉµÄÀ࣬com.building.math.com.building.math.Caculator£¬ºÜÏÔÈ»Õâ¸öÀàÎļþµÄλÖóö´íÁË¡£µ«¼´Ê¹°ÑÕâ¸öÐÂÉú³ÉµÄÀàÎļþ·Åµ½ÕýÈ·µÄλÖÃÒ²²»ÐС£»¹ÊÇ»áÌáʾÎÞ·¨ÕÒµ½ÀàÎļþ¡£ Èç¹û°ÑjwsÎļþ·Åµ½axis¸ùĿ¼Ï£¬·ÃÎÊjwsÎļþ»¹ÊÇûÓÐÎÊÌ⣬µ«·ÃÎÊjws?wsdl»¹ÊÇ»áÓÐÎÊÌ⣬ËäÈ»ÀàÎļþÒѾÔÚÕýÈ·µÄλÖÃÉÏÁË¡£ Éú³ÉµÄclass·´±àÒëºó¿ÉÒÔµÃÖª£¬Éú³ÉµÄÀàÎļþÓëÓÃjavac±àÒëµÄÀàÎļþÊÇÒ»ÑùµÄ¡£ È¥µôjwsÎļþÖеÄpackageÉùÃ÷£¬Ò»ÇоÍÕý³£ÁË¡£Éú³ÉµÄÀà·´±àÒë½á¹ûÒ»Ñù,Ò²¾ÍÊÇ˵axis²¢Ã»ÓиøÀàÖÐÌí¼ÓÈκζîÍâµÄÔ´Âë,ÏëÏëÒ²Ó¦¸ÃÈç´Ë£¬²»ÈçÏÂÃæµÄ²¿Êð·½Ê½¾Í¸Ã³öÎÊÌâÀ²£¡ 2 Custom Deployment - Introducing WSDD 2.1 WSDD and AdminClient • Benefits over JWS deployment ¨C deploy/undeploy multiple services ¨C deploy/undeploy handlers ¨C deploy classes with no source ¨C custom type mapping • Web Service Deployment Descriptor (WSDD) ¨C specifies components to be deployed and undeployed • services, handlers and more ¨C specifies type mappings ¨C download Axis source to get DTD and XML Schema for WSDD • in java/wsdd directory ¨CSimple WSDD examples,only service element include • deploy.wsdd < deployment xmlns =" http://xml.apache.org/axis/wsdd/ " xmlns:java =" http://xml.apache.org/axis/wsdd/providers/java "
< service name =" Caculator " provider =" java:RPC "
< parameter name =" className " value =" com.building.math.Caculator " />
< parameter name =" allowedMethods " value =" * " />
</ service
</ deployment
• undeploy.wsdd < undeployment xmlns =" http://xml.apache.org/axis/wsdd/ "
< service name =" Caculator " /> </ undeployment
• Server-side classes ¨C these are web service implementation classes and classes they use • execute javac com/building/math/Caculator.java ¨C when using Axis webapp • copy .class files to webapps/axis/WEB-INF/classes • copy .jar files to webapps/axis/WEB-INF/lib • for our example only need to copy com.building.math.Caculator to webapps/axis/WEB-INF/classes ¨C a problem if different web services want to use different versions of a class or JAR • solution is to deploy services in different web apps. that each contain Axis • AdminClient uses WSDD ¨C to deploy or undeploy components, pass it a WSDD file java org.apache.axis.client.AdminClient filename.wsdd • modifies server-config.wsdd in the axis webapp WEB-INF directory ¨C to list deployed components java org.apache.axis.client.AdminClient list • outputs server-config.wsdd which is used when the server is restarted to redeploy all previously deployed services ¨C for our example,deploy command is: java org.apache.axis.client.AdminClient deploy.wsdd • Visit WSDL and invoke service to test deploy ¨C get wsdl from http://localhost:8080/axis/services/Caculator?wsdl ¨C change CaculatorClient's targetEndpointAddress to http://localhost:8081/axis/services/Caculator ,recompile and run it wuhaixing ·¢±íÓÚ 2004-10-10 -- 09 : 21 : 22 | ÔĶÁÈ«ÎÄ | ÆÀÂÛ(0) | ÒýÓÃ(trackback0) | ±à¼ e_mail:wuhaixing123@yahoo.com