WebService Jianjun Development Interface Release

zhaozj2021-02-16  86

WebService

No longer introduced, please search for relevant information online

One. Introduction

Service-Terminal

The server-side class diagram is as follows:

ServiceHandler:

Service processing classes, all client requests are submitted to this class, find the corresponding web service processing class through servciename, perform business operations.

Service:

Service interface, Web services developed by all users, must implement the service method in this interface

ServiceConfig:

Service configuration class, read the WebService profile, generate web service mapping map

Servicemodule

Service module class, each user's own WebService program, all corresponds to a module configuration

OA-service.xml

Service configuration file, Servier developed by all users must be configured in this XML, you need to specify the favorite service name and the corresponding service class name. This file supports multi-xml module configuration, when multi-person developed, each person writes his own profile and eventually registered in the OA-Service.xml file.

The above class is located in the com.oa.service.basic package

Client

Client Classification ServiceHandlerProxy and ServiceHandleRexception are written by themselves, and others are automatically generated by JBX through WSDL (WebService Define Language).

ServiceHandlerProxy

The client uses this class to complete the call of WebService

ServiceHandleRexception

WebService call exception class

two. Configure

Service-Terminal

1. Copy OA-Service.jar to the lib directory of web-infers

2. Copy OA-Servier.xml to the class Directory of Web-INF

3. Copy server-config.wsdd to the web-inf directory

4. Configure web.xml, where to join the following configuration

SOAPMONITORSERVICE

SOAP MONITOR Service

org.apache.axis.monitor.soapmonitorvice

SOAPMonitorport

5001

100

Axisservlet

apache-axis servlet

org.apache.axis.transport.http.axisservlet

loadinitlet com.oa.servlet.LoadInitlet

4

SOAPMONITORSERVICE

/ soapmonitor

Axisservlet

/ servlet / axisservlet / *

Axisservlet

*. jws

Axisservlet

/ services / *

test:

Enter http://192.168.0.199:8002/AppModule/services/servicehandler?wsdl in IE

Note, modify the IP address, port, webmodule name to your own, if you can see the WSDL file, the configuration is successful

Client

1. Copy OA-Service.jar to ClassPath, complete the path to add

3. Development example

The following is an example of a common Hello, Word program as an example, demo the Jane Development Process of WebService.

Service-Terminal

1. Create a category: com.oa.service.test. HelloService.java

The code is as follows, pay attention: Service interface must be implemented

Package com.oa.service.test;

Import com.oa.service.basic. *;

Import com.oa.utils.tool;

Public Class HelloService Implements Service {

Public Object Service (Object [] args) throws serviceException {

StringBuffer buffer = new stringbuffer ();

For (int i = 0; args! = null && i

Buffer.Append ("/ r / n client incoming parameters)

.append (i)

.append (":")

.append (args [i]);

}

Tools.log.info (buffer.tostring ());

// Load from OA-Service.xml

Helloname

String helloname = ""

Try {

Helloname =

ServiceConfig.config (). Find ("HelloService"). GetInitParamvalue ("Helloname", "World");

} catch (serviceenotfoundexception e) {

Tools.log.error (E.TOString ());

}

// will "Hello," Helloname as the return value

Return "Hello," Helloname;

}

}

2. Log in to this class into OA-Service.xml

mapping

bean2map

Helloname

World

Client 1. Write a test class, you just want to do, that is:

1) New a serviceHandlerProxy and specifies the URL address of the WebService server in the constructor.

2) Call the Service method, where the first parameter is the server-side WebService implementation class configuration name, here is HelloService, the first parameter Object [] is a list of parameters

The test code is as follows

Package com.oa.service.test;

Import com.oa.service.client. *;

Import junit.framework. *;

Public Class Testhelloservice Extends Testcase {

Private ServiceHandlerProxy ServiceHandlerProxy = NULL;

Protected void setup () throws exception {

Super.setup ();

/ ** @ Todo Verify the constructors * /

// Set the server end address here

String serviceURL = "http://192.168.0.199:8002/oaapp2/services/servicehandler";

ServiceHandlerProxy = New ServiceHandlerProxy (ServiceURL);

}

protected void teardown () throws exception {

ServiceHandlerProxy = NULL;

Super.teardown ();

}

Public void testservice () throws servicehandlerexception {string service1= "helloservice";

Object [] args = new string [] {"Parameter 1", "Parameters 2", "Parameters 3"};

Object [] actueReturn = ServiceHandlerProxy.Service (ServiceName, ARGS);

System.out.println ("server side return value:" actueReturn);

/ ** @ Todo Fill in Test Code * /

}

}

Run the code, the execution result is as follows

Service-Terminal:

Client:

Related documents: OA-service.rar

A little childish, a few sprinkles and release the heads, and it is as good as it is.

Related Comments: Prodige published on 2004-07-22 21:13:59 Published a plenary! encourage!

Ren Weijun published in 2004-07-22 21:15:55 After comment, I found that this stuff is still more practical, and ME likes it :)

Chen Jianjiang published in 2004-07-22 21:21:46 Reviews For complex Object delivery, it can be implemented in bean-> map-> bean, about bean-> map-> bean can pass the beanutils in Common DESCRIBE and POPULATE method implementation

转载请注明原文地址:https://www.9cbs.com/read-13946.html

New Post(0)