WebService Application – Java + Maven Project

WebService is a cross-programming language and cross-operating system platform remote calling technology. The so-called remote call is a method by which a program on a computer a can call an object on another computer b. For example, UnionPay provides a POS card system in a shopping mall, and a POS machine transfer call in a shopping mall. The code of the transfer method actually runs on the bank server. For example, Taobao, Baidu, etc. expose their system services in the form of webservice services, so that third-party websites and programs can call these service functions, which expands the market share of their systems, which is the so-called SOA application.

WebService is an application that exposes an API that can be invoked through the Web to the outside world, that is to say, the application can be invoked through the Web using a programming method. We call the application that calls this WebService the client, and the application that provides this WebService is the server. From a deep level, WebService is a new platform for establishing interoperable distributed applications, a platform, and a set of standards.

Personal feeling: A system developed by the company is associated with many other systems. I am responsible for associating two of these systems. One is used as a server and called by the other system; Client, call another system. This is also my first contact with webservice. It feels very interesting and amazing. I will record the process of using it here.

1. Development server

As a server-side development, it is the interface through which other systems call our system and send data to us. I use Cxf technology

1. Add the introduction of cxf in pom.xml


org.apache .cxf
cxf-rt-frontend-jaxws
2.7.2

< br> org.apache.cxf
cxf-rt-transports-http
2.7.2


org.apache.cxf
cxf-rt-transports -http-jetty
2.7.2
provided

2. Create webservice interface


< /p>

3. Configure applicationContext.xml

where id is the method Name; implementor is the interface path; address is what the client calls need to use, here is the full name based on personal thoughts.

< span style="font-family:Simsun">4. Write a test method locally to test whether it can be connected

/*
* webservice test
* @param args
*/
public static void main(String args[]){
JaxWsProxyFactoryBean factoryBean = new JaxWsProxyFactoryBean();
factoryBean.setServiceClass(WebServiceManager.class);
Address(” factoryBean.” http://localhost:8880/cps-server/webservice/exchange?wsdl”);
WebServiceManager readerService = (WebServiceManager)factoryBean.create();
EventBean bean = new EventBean();
Bean .setEvent_System_Name(new String(“centralized monitoring” ));
bean.setHost_Name(new String(“F3-10-11 Zhanhua Monitoring Database Host”));
bean.setEvent_Desc(new String(“Table space usage rate exceeds 100%”));
bean.setEvent_Level(new String(“5”));
bean.setEvent_TypeF(new String(“databa”));
bean.setEvent_TypeF_Name(new String(“table space usage rate”)) ;
bean.setHost_IP(new String(“192.210.0.11”));
bean.setEvent_Level_Name(new String(“serious alarm”));
bean.setEvent_Happend_Time(new String(“2016-10 -27 15:00:00”));
        
        int i = readerService.createMonitorInfor(bean);  
        System.out.println(“成功没??????????? ????????????”+i+”++++++++++++++++++++”);


}




Second, develop the client

As a client, we call the interfaces of other systems. I looked at their interfaces and asked about the technology used by their webservices. What they use is Another technology—axis, so I learned about another technology. The overall feeling is that this technology is not as easy to use as cxf and is too complicated.

< /p>

1. In pom. Introducing the axis package in xml


org.apache.axis
axis
1.4
< br>
javax.xml
jaxrpc-api
1.1
< /p>

2. On the client Create a server-side interface file (no need to implement), just copy it over

3. Create a copy on the client Files in jws format, copied from the server

4. Just call it where the client needs to use it, and test whether it works, similar to the above test method

< p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px"> Among them, targetEendPoint is the server interface url; space is the package where the server interface is located;

< p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px"> Reprint address: http://www.voidcn.com/article/p-criqrzze-bpn.html

WebService is a cross-programming Language and remote calling technology across operating system platforms. The so-called remote call is a method by which a program on a computer a can call an object on another computer b. For example, UnionPay provides a POS card system in a shopping mall, and a POS machine transfer call in a shopping mall. The code of the transfer method actually runs on the bank server. For example, Taobao, Baidu, etc. expose their system services in the form of webservice services, so that third-party websites and programs can call these service functions, which expands the market share of their systems, which is the so-called SOA application.

WebService is an application that exposes an API that can be invoked through the Web to the outside world, that is to say, the application can be invoked through the Web using a programming method. We call the application that calls this WebService the client, and the application that provides this WebService is the server. From a deep level, WebService is a new platform for establishing interoperable distributed applications, a platform, and a set of standards.

Personal feeling: A system developed by the company is associated with many other systems. I am responsible for associating two of these systems. One is used as a server and called by the other system; Client, call another system. This is also my first contact with webservice. It feels very interesting and amazing. I will record the process of using it here.

1. Development server

As a server-side development, it is the interface through which other systems call our system and send data to us. I use Cxf technology

1. Add the introduction of cxf in pom.xml


org.apache .cxf
cxf-rt-frontend-jaxws
2.7.2

< br> org.apache.cxf
cxf-rt-transports-http
2.7.2


org.apache.cxf
cxf- rt-transports-http-jetty
2.7.2
provided

2. Create webservice interface


3. Configure applicationContext.xml

< /p>

Among them, id is the name of the method; implementor is the interface path; address is what the client calls need to use, here is the full name based on personal thoughts.

< span style="font-family:Simsun">4. Write a test method locally to test whether it can be connected

/*
* webservice test
* @param args
*/
public static void main(String args[]){
JaxWsProxyFactoryBean factoryBean = new JaxWsProxyFactoryBean();
factoryBean.setServiceClass(WebServiceManager.class);
Address(” factoryBean.” http://localhost:8880/cps-server/webservice/exchange?wsdl”);
WebServiceManager readerService = (WebServiceManager)factoryBean.create();
EventBean bean = new EventBean();
Bean .setEvent_System_Name(new String(“Concentration Monitoring”));
bean.setHost_Name(new String(“F3-10-11 Zhanhua Monitoring Database Host”));
bean.setEvent_Desc(new String(“Table space usage rate exceeds 100%”) );
bean.setEvent_Level(new String(“5”));
bean.setEvent_TypeF(new String(“databa”));
bean.setEvent_TypeF_Name(new String(“table space usage rate” ));
bean.setHost_IP(new String(“192.210.0.11”));
bean.setEvent_Level_Name(new String(“serious alarm”));
bean.setEvent_Happend_Time(new String(“2016 -10-27 15:00:00”));
        
        int i = readerService.createMonitorInfor(bean);  
        System.out.println(“成功没????????? ???????????”+i+”++++++++++++++++++++”);

< p style="margin-top:0px; margin-bottom:0px; padding-top:0px; padding-bottom:0px; font-family:Arial; font-size:14px">
}




2. Develop client

As a client, we call the interfaces of other systems. I looked at their interfaces and asked about the technologies used by their webservices. They used It is another technology—axis, so I learned about another technology. The overall feeling is that this technology is not as easy to use as cxf, and it is too complicated.

< /p>

1. In pom. Introducing the axis package in xml


org.apache.axis
axis
1.4
< br>
javax.xml
jaxrpc-api
1.1
< /p>

2. On the client Create a server-side interface file (no need to implement), just copy it over

3. Create a A file in jws format, copied from the server

4. Just call it where the client needs to use it, and test whether it works, similar to the above test method

Among them, targetEendPoint is the server interface url; space is the server The package where the interface is located;

WebService is a cross-programming language and cross-operating system platform remote call technology. The so-called remote call is a method by which a program on a computer a can call an object on another computer b. For example, UnionPay provides a POS card system in a shopping mall, and a POS machine transfer call in a shopping mall. The code of the transfer method actually runs on the bank server. For example, Taobao, Baidu, etc. expose their system services in the form of webservice services, so that third-party websites and programs can call these service functions, which expands the market share of their systems, which is the so-called SOA application.

WebService is an application that exposes an API that can be invoked through the Web to the outside world, that is to say, the application can be invoked through the Web using a programming method. We call the application that calls this WebService the client, and the application that provides this WebService is the server. From a deep level, WebService is a new platform for establishing interoperable distributed applications, a platform, and a set of standards.

Personal feeling: A system developed by the company is associated with many other systems. I am responsible for associating two of these systems. One is used as a server and called by the other system; Client, call another system. This is also my first contact with webservice. It feels very interesting and amazing. I will record the process of using it here.

1. Development server

As a server-side development, it is the interface through which other systems call our system and send data to us. I use Cxf technology

1. Add the introduction of cxf in pom.xml


org.apache .cxf
cxf-rt-frontend-jaxws
2.7.2

< br> org.apache.cxf
cxf-rt-transports-http
2.7.2


org.apache.cxf
cxf-rt-transports -http-jetty
2.7.2
provided

2. Create webservice interface


< /p>

3. Configure applicationContext.xml

where id is the method Name; implementor is the interface path; address is what the client calls need to use, here is the full name based on personal thoughts.

< span style="font-family:Simsun">4. Write a test method locally to test whether it can be connected

/*
* webservice test
* @param args
*/
public static void main(String args[]){
JaxWsProxyFactoryBean factoryBean = new JaxWsProxyFactoryBean();
factoryBean.setServiceClass(WebServiceManager.class);
Address(” factoryBean.” http://localhost:8880/cps-server/webservice/exchange?wsdl”);
WebServiceManager readerService = (WebServiceManager)factoryBean.create();
EventBean bean = new EventBean();
Bean .setEvent_System_Name(new String(“centralized monitoring” ));
bean.setHost_Name(new String(“F3-10-11 Zhanhua Monitoring Database Host”));
bean.setEvent_Desc(new String(“Table space usage rate exceeds 100%”));
bean.setEvent_Level(new String(“5”));
bean.setEvent_TypeF(new String(“databa”));
bean.setEvent_TypeF_Name(new String(“table space usage rate”)) ;
bean.setHost_IP(new String(“192.210.0.11”));
bean.setEvent_Level_Name(new String(“serious alarm”));
bean.setEvent_Happend_Time(new String(“2016-10 -27 15:00:00”));
        
        int i = readerService.createMonitorInfor(bean);  
        System.out.println(“成功没??????????? ????????????”+i+”++++++++++++++++++++”);


}




二、开发客户端

    作为客户端,我们是调用其他系统的接口,我当时是看了他们的接口,寻问了他们webservice所使用的技术,他们使用的是另外一种技术—axis,所以我又了解了一种技术,总体感觉还是这个技术没有cxf好用,太复杂。

1.在pom.xml里引入axis的包


   org.apache.axis
   axis
   1.4
  

  
   javax.xml
   jaxrpc-api
   1.1
  

2.在客户端创建一份服务端的接口文件(不需要实现),拷贝过来就行

3.在客户端创建一份jws格式的文件,从服务端拷贝过来

4.在客户端需要用到的地方调用即可,测试是否能通,和上面的测试方法类似

其中,targetEendPoint是服务端接口url;space是服务端接口所在包;

Leave a Comment

Your email address will not be published.