Servlet plays a major role in web services. It is responsible for parsing soap files (message and attachment encapsulation) and verifying soap messages using wsdl. As a basic programming method, servlet can be used to parse soap messages, especially for soap messages with attachments. This is transparent, but servlet cannot be used as a Web service, of course, JAXM can be expanded. Currently, all the projects that support web services implement servlet functions at the underlying layer to complete HTTP + SOAP communication, there is no need for programmers to consider the communication process of HTTP-based SOAP messages (do not misunderstand that the Service Program for HTTP Communication on the java platform is servlet/jsp, but now you don't need servlet to communicate with jsp, isn't it a conflict? There is no conflict with the facts. Remember that the underlying layer has implemented the servlet function, and the specific communication has been managed by itself.) Service programming is directly promoted to the business logic. Of course, sometimes you can write a servlet to parse SOAP messages, which is just SOAP communication (servlet cannot be described as a service ).
The following describes the relationship between the underlying layer and web services Based on the configuration file:
Review the servlet ing mode. As we know, servlets are inherited from javax. servlet. http. HttpServlet, loaded to the JVM on the server side for execution, and then output the html stream to the client.
Servlet's web. xml file (located in the webapps/foo/WEB-INF directory ):
<? Xml version = "1.0" encoding = "UTF-8"?>
<! DOCTYPE web-app PUBLIC "-// Sun Microsystems, Inc. // DTD Web Application 2.2 // EN"
Http://java.sun.com/j2ee/dtds/web-app_2.2.dtd>
<Web-app>
<Servlet-mapping>
<Servlet-name> invoker </servlet-name>
<Url-pattern>/servlet/* </url-pattern>
</Servlet-mapping>
</Web-app>
Invoker servlet is actually: org. apache. catalina. servlets. InvokerServlet
Provides small service programs by class name. For example, if you call foo/servlet/HelloServlet,
Invoker servlet will load the HelloServlet (if it is in its class path) and execute it.
Looking at the web. xml above, it seems that only one servlet ing is provided, and no invoker servlet is defined.
In fact, invoker servlet is defined in web. xml in the conf directory of tomcat ::