WebService technology--server side

Source: Internet
Author: User
Tags wsdl

1.webservice implementation of single sign-on specific logic is
① Web side as a client, request the WI community backstage, login request
②wi Community Background Verification T, after verifying the error, go to the login logic and go directly to the Welcome page
③ If there is an error, encapsulate the error XML and return it to the iSoftStone Web side
2.wi Community Backstage is actually the code to add the WebService server
the 3.WI community will actually write the code as a client
This is due to my self-test, I need to simulate the soft web side of the client to request XML format data requests, so, the logic of the actual self-test is: Through the interface testing tool provided by the software to generate the request xml-in the WI Community Background Project test class to send these XML requests- The WI community backstage as a server for corresponding logical response
4. As the server side first need to compile a primitive first class
This initial class is actually a portal, the code can not write, as long as there is a way to do, after generating the server-side code, you can rewrite this part of the code, my initial class code is as follows

  
 
  1. package com.ht.ilcom.webservice;
  2. public class HtWebService {
  3. public void execute(String requestXML){
  4. }
  5. }

compile command:
Javac Htwebservice.java
5. Generate WSDL command
%axis2_home%\bin\ JAVA2WSDL-CP. -CN com.ht.ilcom.webservice.htwebservice-of htwebservice.wsdl
(change it according to your own directory)
6. In fact, we need to generate the server-side code through a WSDL
①webservice server-side code was originally written by hand, requires a great understanding of the technology, and is prone to error. And now because there are a lot of framework technology, so we can generate the above WSDL file, and then choose a framework technology, directly generate WebService technology code, eliminating the time to learn the underlying WebService technology, directly write their own business logic can be. (This is good when bad, hehe)
② because we are using AXIS2 technology here, Apache has provided several framework technologies
Axis2 generate server-side code in 4 ways, including deploying POJOs, Building the service Using AXIOM, generating the service using ADB, generating the service using XMLBeans, generating the service using JiBX
This In the use of the ADB because the Chinese code friends said that time is limited, we have to choose to believe most of the time. The
command is as follows
%axis2_home%\bin\wsdl2java-uri resources\meta-inf\htwebservice.wsdl-p com.ht.ilcom.webservice.adb-d adb-s-ss-sd-ssi-o build\service
The service under the Bulid folder is the code we just generated
Our logic is to write to Htwebserviceskeleton.java in this class
Note: After writing the logic, execute the 9 ant build command

7. Here's a little bit more about WebService's basic configuration
① first JDK is sure to have, minimum version 1.5, and configure environment variables
② Download Axis2 project, extract to target file
③ You can also download Axis2.war and put it into your project engine (like Tomcat's WebApp) extract the project
④ set AXIS2 environment variable axis2_home, this is important, many commands are based on this, do not ignore this step
⑤ After completing these steps, we should execute just the first class of logic-compile as a class file-generate the WSDL file via java2wsdl-and generate WebService server-side code through Wsdl2java
8. After generating the code, you need to write your own logic.
① write his own logic, need to be aware of all the classes you reference (either the jar is the original service in the project), if it is something in the jar, we can copy the jar package used to the Axis2 project Lib, because when the next use of ant, Will scan the jar packages used in lib yourself.
② If you need to use other service methods in your project, it's a good idea to write a separate copy of the WebService package.

9. We need to build an AAR file from Ant
① first understand this principle

*首先是Java的编译和运行机制,从.java编译为.class的过程中,javac会默认按照编译所在操作系统的默认编码读取源代码,并编译成内部为UTF-8编码的.class,而在java虚拟机执行的过程中,会按照程序运行所在操作系统的默认编码,将UTF-8编码再次进行转换。通过这种两次转换的方式,Java实现了对多语言的支持。***

② Workaround

 
   
  
  1. < Span class= "pun" >< javac encoding = " Utf-8 " Destdir = " ${compile.dir} " debug = "on"
  2. ....
  3. </ Span class= "PLN" >javac >

Use the Javac in Ant's Build.xml to add a encoding= "Utf-8" to it.
③ the execution of the command succeeds, we get the htwebserviceservice.aar file in the directory Build/service/build/lib, which is the final file
We simply copy the Htwebserviceservice.aar file to the project's Services folder,

The last step, modify the Service.list file, such as

Validation
View the list of services
Http://localhost:8080/axis2/services/listServices

View WSDL file
http://localhost:8080/axis2/services/StockQuoteService?wsdl

viewing XSD files
Http://localhost:8080/axis2/services/StockQuoteService?xsd

# # #其他记录 # #
① new Tables Member_info, Ec_info, Order_info, Client_ctid
② Actually, I did not use the first class, because the iSoftStone gave me a good WSDL file, the required method has been declared complete, I directly use this WSDL, through the Wsdl2java generated the server code.



From for notes (Wiz)

WebService technology--server side

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.