In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
The editor today takes you to understand how to understand the complex types of mapping arrays in J2EE web service development. The knowledge points in this article are introduced in great detail. Friends who feel helpful can browse the content of the article with the editor, hoping to help more friends who want to solve this problem find the answer to the problem. Let's follow the editor to learn more about how to understand the complex types of mapping arrays in J2EE web service development.
The reason why array types are solemnly recorded as the implementation of parameters in the call to web service is that the implementation of arrays in j2ee web service is not an easy problem. At least this is the case when implemented in Jboss's j2ee web service. In the axis implementation of apache, the passing of arrays as parameters is not worth mentioning at all, and can be achieved with the help of tools.
Specific implementation:
A class that is implemented as a J2EE web service service must implement the interface of java.rmi.Remote:
Package array; import java.rmi.Remote; import java.rmi.RemoteException; public interface CountUser extends Remote {public int countUser (User [] user) throws RemoteException;}
Classes that specifically implement the remote interface:
Package array; public class CountUserImpl implements CountUser {public int countUser (User [] user) {for ("name" + user [I] .getName () + "phone" + user [I] .getphone () + "birthday" + user [I]. GetBirthDay ());} return user.length;}}
The class passed as an array parameter:
Package array; import java.util.Date; public class User {private String name; private String phone; private Date birthDay; public User () {} public User (String name,String phone,Date birthDay) {this.name=name; this.phone=phone; this.birthDay=birthDay;} public void setName (String name) {this.name=name } public void setPhone (String phone) {this.phone = phone;} public void setBirthDay (Date birthDay) {this.birthDay = birthDay;} public String getName () {return name;} public String getPhone () {return phone;} public Date getBirthDay () {return birthDay }}
Use the wstools tool under Jboss_Home/bin to generate the three files necessary to deploy j2ee web service, the jax-rpc mapping file, the web service descriptor file, and the wsdl document. The configuration file jboss-config.xml class for the wstools tool is as follows:
< ?xml version="1.0" encoding="UTF-8"?> < configuration xmlns="http://www.jboss.org/jbossws-tools" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.jboss.org/jbossws-tools http://www.jboss.org/jbossws-tools/schema/jbossws-tool_1_0.xsd" < java-wsdl> < service name="ServiceBeanInterface1" style="rpc" endpoint="array.ServiceBeanInterface1"/> < namespaces target-namespace="http://array" type-namespace="http://array"/> < mapping file="ServiceBeanInterface1.xml"/> < webservices servlet-link="ServiceBeanInterface1"/> < /java-wsdl> < /configuration>Use the wstools-cp array.CountUser-config jboss-config.xml command to generate the three files required to deploy the web service. In addition, you have to publish the CountUser interface as servlet in the web.xml file.
< servlet> < display-name>CountUser Servlet
< /display-name> < servlet-name>CountUser
< /servlet-name> < servlet-class>Array.CountUserImpl
< /servlet-class> < /servlet> < servlet-mapping> < servlet-name>CountUser
< /servlet-name> < url-pattern>/ CountUser
< /url-pattern> < /servlet-mapping> < servlet-mapping> < servlet-name>CountUser
< url-pattern>/ services/*
< /servlet-mapping>It's easy to do this alone, but the wstools tool does not properly implement the mapping of User [] in the mapping file. Therefore, you also need to manually add the following code to achieve the mapping between User [] to xml.
< java-xml-type-mapping> < java-type>Array.User []
< /java-type> < root-type-qname xmlns:typeNS='http://array'>TypeNS:User.Array
< /root-type-ame> < qname-scope>ComplexType
< /qname-scope> < /java-xml-type-mapping>Package it into a war file and deploy it. The implementation of the J2EE web service server is complete. The Jboss version 4.04 used.
Thank you for your reading, the above is the whole content of "how to understand the complex types of mapping arrays in J2EE web service development". Friends who learn to learn to do it quickly. I believe that the editor will certainly bring you better quality articles. Thank you for your support to the website!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.