一、Axis2的下载和安装
1.可从
http://ws.apache.org/axis2/
下载Axis2的最新版本:
可以下载如下两个zip包:
axis2-1.5.4-bin.zip
axis2-1.5.4-war.zip
其中 axis2-1.5.4-bin.zip文件中包含了Axis2中所有的jar文件,
axis2-1.5.4-war.zip文件用于将WebService发布到Web容器中。
2.将axis2-1.5.4-war.zip文件解压到相应的目录,将目录中的axis2.war文件放到<Tomcat安装目录>\webapps目录中,
并启动Tomcat,在浏览器地址栏中输入如下的URL:
http://localhost:8080/axis2/
,如看到axis2的主页面则安装成功。
二、编写和发布WebService
(1)用POJO形式发布(无需配置)
在Axis2中不需要进行任何的配置,就可以直接将一个简单的POJO发布成WebService。
其中POJO中所有的public方法将被发布成WebService方法。
示例代码如下:
public
class HelloService {
public String sayHello(){
return
"hello";
public String sayHelloToPerson(String name){
if(name==
null){
name =
"nobody";
return
"hello,"+name;
编译HelloService类后,将HelloService.class文件放到<Tomcat安装目录>\webapps\axis2\WEB-INF\
pojo
目录中
(如果没有pojo目录,则建立该目录)。现在我们已经成功将HelloService类发布成了WebService。
在浏览器地址栏中输入如下的URL:
http://localhost:8080/axis2/services/listServices
在浏览器地址栏中输入如下的两个URL来分别测试sayHelloToPerson和sayHello方法:
1.http://localhost:8080/axis2/services/HelloService/sayHello
2.http://localhost:8080/axis2/services/HelloService/sayHelloToPerson?name=bill
页面显示如下结果:
<
ns:sayHelloToPersonResponse
xmlns:ns=
"http://ws.apache.org/axis2"
>
<
return
>hello,bill
</
return
>
</
ns:sayHelloToPersonResponse
>
在编写、发布和测试WebService时应注意如下几点:
1. POJO类不能使用package关键字声明包。
2. Axis2在默认情况下可以热发布WebService,也就是说,将WebService的.class文件复制到pojo目录中时,
Tomcat不需要重新启动就可以自动发布WebService。
如果想取消Axis2的热发布功能,可以打开<Tomcat安装目录>\webapps\axis2\WEB-INF\conf\axis2.xml,
找到如下的配置代码:
<
parameter
name=
"hotdeployment"
>true
</
parameter
>
将true改为false即可。要注意的是,Axis2在默认情况下虽然是热发布,但并不是热更新.
也就是说,一旦成功发布了WebService,再想更新该WebService,就必须重启Tomcat。
这对于开发人员调试WebService非常不方便,因此,在开发WebService时,可以将Axis2设为热更新。
在axis2.xml文件中找到
<
parameter
name=
"hotupdate"
>false
</
parameter
>
将false改为true即可。
3. 在浏览器中测试WebService时,如果WebService方法有参数,需要使用URL的请求参数来指定该WebService方法
参数的值,请求参数名与方法参数名要一致,例如,要测试sayHelloToPerson方法,请求参数名应为name,如上面的URL所示。
4. 发布WebService的pojo目录只是默认的,如果读者想在其他的目录发布WebService,
可以打开axis2.xml文件,并在<axisconfig>元素中添加如下的子元素:
<
deployer
extension=
".class"
directory=
"my"
class=
"org.apache.axis2.deployment.POJODeployer"
/>
上面的配置允许在<Tomcat安装目录>\webapps\axis2\WEB-INF\my目录中发布WebService。
例如,将本例中的HelloService.class复制到my目录中也可以成功发布
(但要删除pojo目录中的SimpleService.class,否则WebService会重名)。
(2)使用services.xml配置文件发布
用Axis2实现Web Service,虽然可以将POJO类放在axis2\WEB-INF\pojo目录中直接发布成Web Service,
这样做不需要进行任何配置,但这些POJO类不能在任何包中。这似乎有些不方便.
为此,Axis2也允许将带包的POJO类发布成Web Service。先实现一个POJO类,代码如下:
package com.sinosoft.webservice;
public
class HelloServiceNew {
public String sayHelloNew(){
return
"hello";
public String sayHelloToPersonNew(String name){
if(name==
null){
name =
"nobody";
return
"hello,"+name;
public
void updateData(String data){
System.out.println(data+
" 已更新。");
要想将HelloServiceNew类发布成Web Service,需要一个services.xml文件,
这个文件需要放在META-INF目录中,该文件的内容如下:
<?
xml
version=
"1.0"
encoding=
"UTF-8"
?>
<
service
name=
"HelloServiceNew"
>
<
description
>
Web Service例子
</
description
>
<
parameter
name=
"ServiceClass"
>
com.sinosoft.webservice.HelloServiceNew
</
parameter
>
<
messageReceivers
>
<
messageReceiver
mep=
"http://www.w3.org/2004/08/wsdl/in-out"
class=
"org.apache.axis2.rpc.receivers.RPCMessageReceiver"
/>
<
messageReceiver
mep=
"http://www.w3.org/2004/08/wsdl/in-only"
class=
"org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"
/>
</
messageReceivers
>
</
service
>
其中<service>元素用于发布Web Service,一个<service>元素只能发布一个WebService类,
name属性表示WebService名,如下面的URL可以获得这个WebService的WSDL内容:
http://localhost:8080/axis2/services/HelloServiceNew?wsdl
其中name属性名就是上面URL中"?"和"/"之间的部分。
<description>元素表示当前Web Service的描述,<parameter>元素用于设置WebService的参数,
在这里用于设置WebService对应的类名。
在这里最值得注意的是<messageReceivers>元素,该元素用于设置处理WebService方法的处理器。
例如,sayHelloNew方法有一个返回值,因此,需要使用可处理输入输出的RPCMessageReceiver类,
而updateData方法没有返回值,因此,需要使用只能处理输入的RPCInOnlyMessageReceiver类。
使用这种方式发布WebService,必须打包成.aar文件,.aar文件实际上就是改变了扩展名的.jar文件。
现在建立了两个文件:HelloServiceNew.java和services.xml。
将HelloServiceNew.java编译,生成HelloServiceNew.class。
services.xml和HelloServiceNew.class文件的位置如下:
D:\ws\ com\sinosoft\webservice\HelloServiceNew.class
D:\ws\META-INF\services.xml
在windows控制台中进入ws目录,并输入如下的命令生成.aar文件.
jar cvf ws.aar .
实际上,.jar文件也可以发布webservice,但axis2官方文档中建议使用.aar文件发布webservice.
最后将ws.aar文件复制到<Tomcat安装目录>\webapps\axis2\WEB-INF\services目录中,
启动Tomcat后,就可以调用这个WebService了。
另外services.xml文件中也可以直接指定WebService类的方法,如可以用下面的配置代码来发布WebService
<
service
name=
" HelloServiceNew "
>
<
description
>
Web Service例子
</
description
>
<
parameter
name=
"ServiceClass"
>
com.sinosoft.webservice.HelloServiceNew
</
parameter
>
<
operation
name=
"sayHello"
>
<
messageReceiver
class=
"org.apache.axis2.rpc.receivers.RPCMessageReceiver"
/>
</
operation
>
<
operation
name=
"updateData"
>
<
messageReceiver
class=
"org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver"
/>
</
operation
>
</
service
>
三、 用Java实现调用WebService的客户端程序
WebService是为程序服务的,只在浏览器中访问WebService是没有意义的。调用WebService的客户端代码如下:
import javax.xml.namespace.QName;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.rpc.client.RPCServiceClient;
public
class TestMain {
public
static
void main(String args[])
throws AxisFault{
RPCServiceClient serviceClient =
new RPCServiceClient();
Options options = serviceClient.getOptions();
EndpointReference targetEPR =
new EndpointReference(
"http://localhost:8080/axis2/services/HelloService");
options.setTo(targetEPR);
Object[] opAddEntryArgs =
new Object[] {
"美女"};
Class[] classes =
new Class[] {String.
class};
QName opAddEntry =
new QName(
"http://ws.apache.org/axis2",
"sayHelloToPerson");
System.out.println(serviceClient.invokeBlocking(opAddEntry, opAddEntryArgs, classes)[
0]);
输出结果为:
hello,美女
在编写客户端代码时应注意如下几点:
1. 客户端代码需要引用很多Axis2的jar包,如果读者不太清楚要引用哪个jar包,
可以在Eclipse的工程中引用Axis2发行包的lib目录中的所有jar包。
2. 在本例中使用了RPCServiceClient类的invokeBlocking方法调用了WebService中的方法。
invokeBlocking方法有三个参数,其中第一个参数的类型是QName对象,表示要调用的方法名;
第二个参数表示要调用的WebService方法的参数值,参数类型为Object[];
第三个参数表示WebService方法的返回值类型的Class对象,参数类型为Class[]。
当方法没有参数时,invokeBlocking方法的第二个参数值不能是null,而要使用new Object[]{}。
3. 如果被调用的WebService方法没有返回值,应使用RPCServiceClient类的invokeRobust方法,
该方法只有两个参数,它们的含义与invokeBlocking方法的前两个参数的含义相同。
4. 在创建QName对象时,QName类的构造方法的第一个参数表示WSDL文件的命名空间名,
也就是<wsdl:definitions>元素的targetNamespace属性值。
四、用wsdl2java简化客户端的编写
Axis2提供了一个wsdl2java.bat命令可以根据WSDL文件自动产生调用WebService的代码。
wsdl2java.bat命令可以在<Axis2安装目录>/bin目录中找到。
在使用wsdl2java.bat命令之前需要设置AXIS2_HOME环境变量,该变量值是<Axis2安装目录>。
在Windows控制台输出如下的命令行来生成调用WebService的代码:
%AXIS2_HOME%\bin\wsdl2java -uri
http://localhost:8080/axis2/services/HelloService?wsdl
-p client -s -o stub
其中-url参数指定了wsdl文件的路径,可以是本地路径,也可以是网络路径。
-p参数指定了生成的Java类的包名,-o参数指定了生成的一系列文件保存的根目录。
在执行完上面的命令后,就会发现在当前目录下多了个stub目录,
在stub/src/client目录可以找到一个HelloServiceStub.java文件,
该文件复杂调用WebService,可以在程序中直接使用这个类,代码如下:
package client;
public
class StupTest {
public
static
void main(String[] args)
throws Exception
HelloServiceStub stub =
new HelloServiceStub();
HelloServiceStub.SayHelloToPerson gg =
new HelloServiceStub.SayHelloToPerson();
gg.setName(
"美女");
System.out.println( stub.sayHello().get_return());
System.out.println(stub.sayHelloToPerson(gg).get_return());
输出结果如下:
hello
hello,美女
上面的代码大大简化了调用WebService的步骤,并使代码更加简洁。
但要注意的是,wsdl2java.bat命令生成的Stub类将WebService方法的参数都封装在了相应的类中,
类名为方法名,例如,sayHelloToPerson方法的参数都封装在了SayHelloToPerson类中,
要想调用sayHelloToPerson方法,必须先创建SayHelloToPerson类的对象实例。
平均薪酬38K! 前端工程师凭什么这么值钱?
2019年,这类程序员需求增速达174%?原因竟是...
<c:
if test=
"${ReleaseResult==null}"> <p
class=
"errorMsg"><%=ToshibaMFP.getInstance().resourceService.getMessageByID(language,
"INFO-0014")%></p>
</c:
if>
if(result !=
null && result.length() >
0){
if(result.startsWith(
"INF0009")){
request.setAttribute(
"ReleaseResult",ToshibaMFP.getInstance().resourceService.getMessageByID(language,
"INFO-0015"));
}
else{
request.setAttribute(
"ReleaseResult",ToshibaMFP.getInstance().resourceService.getMessageByID(language,
"INFO-0016"));
String printerIp = req.getRemoteAddr();
String releaseCode = req.getParameter(
"release_code");
VPrinter printer = ToshibaMFP.getInstance().getPrinterByIpAddress(
printerIp);
if (CommonUtil.isBlank(printer.serialNumber)) {
printer.serialNumber = printer.readerName;
String screenPrefix =
"wvga";
if (
"SVGA".equalsIgnoreCase(printer.screenType)) {
screenPrefix =
"svga";
String result = ToshibaMFP.getInstance().httpService.releaseJobByCode(
printer, releaseCode);
if (
"SVGA".equalsIgnoreCase(screenPrefix)) {
resp.sendRedirect(
"/toshibamfp/svga/releaseCode.jsp?result="
+ result
+
"&printerIp="
+ printerIp
+
"&language="
+ MfpConfigure.getInstance().getProperty(
CommonConstant.PARAM_DEFAULT_LANGUAGE));
}
else {
resp.sendRedirect("/toshibamfp/wvga/releaseCode.jsp?result=
+ result
+
"&printerIp="
+ printerIp
+
"&language="
+ MfpConfigure.getInstance().getProperty(
CommonConstant.PARAM_DEFAULT_LANGUAGE));
var releaseCode = document.getElementById(
"release_code");
releaseCode.value = releaseCode.value +
'1';
function press2(e)
var releaseCode = document.getElementById(
"release_code");
releaseCode.value = releaseCode.value +
'2';
function press3(e)
var releaseCode = document.getElementById(
"release_code");
releaseCode.value = releaseCode.value +
'3';
function press4(e)
var releaseCode = document.getElementById(
"release_code");
releaseCode.value = releaseCode.value +
'4';
function press5(e)
var releaseCode = document.getElementById(
"release_code");
releaseCode.value = releaseCode.value +
'5';
function press6(e)
var releaseCode = document.getElementById(
"release_code");
releaseCode.value = releaseCode.value +
'6';
function press7(e)
var releaseCode = document.getElementById(
"release_code");
releaseCode.value = releaseCode.value +
'7';
function press8(e)
var releaseCode = document.getElementById(
"release_code");
releaseCode.value = releaseCode.value +
'8';
function press9(e)
var releaseCode = document.getElementById(
"release_code");
releaseCode.value = releaseCode.value +
'9';
function press0(e)
var releaseCode = document.getElementById(
"release_code");
releaseCode.value = releaseCode.value +
'0';
function releaseCode(e)
var releaseCode = document.getElementById(
"release_code");
if(releaseCode.value !=
'')
document.getElementById(
"action_form").submit();
function backspace(e)
var releaseCode = document.getElementById(
"release_code");
if(releaseCode.value !=
'')
releaseCode.value = releaseCode.value.substring(
0,releaseCode.value.length-
1);
<tr height=
"75px;">
<td><button type=
"button"
class=
"numButton" onclick=
"press1(event)"><font color=
"black" size=
"6">
1</font></button></td>
<td style=
"padding-left:25px;padding-right:25px;"><button type=
"button"
class=
"numButton" onclick=
"press2(event)"><font color=
"black" size=
"6">
2</font></button></td>
<td><button type=
"button"
class=
"numButton" onclick=
"press3(event)"><font color=
"black" size=
"6">
3</font></button></td>
<tr height=
"75px;">
<td><button type=
"button"
class=
"numButton" onclick=
"press4(event)"><font color=
"black" size=
"6">
4</font></button></td>
<td style=
"padding-left:25px;padding-right:25px;"><button type=
"button"
class=
"numButton" onclick=
"press5(event)"><font color=
"black" size=
"6">
5</font></button></td>
<td><button type=
"button"
class=
"numButton" onclick=
"press6(event)"><font color=
"black" size=
"6">
6</font></button></td>
<tr height=
"75px;">
<td><button type=
"button"
class=
"numButton" onclick=
"press7(event)"><font color=
"black" size=
"6">
7</font></button></td>
<td style=
"padding-left:25px;padding-right:25px;"><button type=
"button"
class=
"numButton" onclick=
"press8(event)"><font color=
"black" size=
"6">
8</font></button></td>
<td><button type=
"button"
class=
"numButton" onclick=
"press9(event)"><font color=
"black" size=
"6">
9</font></button></td>
<tr height=
"75px;">
<td><button type=
"button"
class=
"numButton" onclick=
"press0(event)"><font color=
"black" size=
"6">
0</font></button></td>
<td style=
"padding-left:25px;padding-right:25px;"><button type=
"button"
class=
"numButton" onclick=
"backspace(event)"><font color=
"black" size=
"5"><%=ToshibaMFP.getInstance().resourceService.getMessageByID(language,
"Delete")%></font></button></td>
<td><button type=
"button"
class=
"okButton" onclick=
"releaseCode(event)"><font color=
"white" size=
"5"><%=ToshibaMFP.getInstance().resourceService.getMessageByID(language,
"Confirm")%></font></button></td>
String loginAccount = req.getParameter(
"login_account");
String loginPassword = req.getParameter(
"login_password");
String loginDomain = req.getParameter(
"login_domain");
String cardId = req.getParameter(
"card_id");
String printIp = req.getRemoteAddr();
VPrinter printerA = ToshibaMFP.getInstance().getPrinterByIpAddress(
printIp);
String serialNumber = printerA.serialNumber;
String result = ToshibaMFP.getInstance().httpService.cardRegister(
loginAccount, loginDomain, loginPassword, cardId, serialNumber);
req.getSession().setAttribute(
"RegisterResult", result);
String screenType = printerA.screenType;
if (
"OK:Success".equalsIgnoreCase(result)) {
VPrinter printer = ToshibaMFP.getInstance()
.getPrinterBySerialNumber(serialNumber);
VUser user = ToshibaMFP.getInstance().getUserByName(loginAccount);
MDSUserInfoType userInfo =
new MDSUserInfoType();
userInfo.setName(user.userName);
userInfo.setPassword(user.password);
userInfo.setDomain(loginDomain);
userInfo.setUserID(user.userId);
if (user.emailAddress !=
null) {
userInfo.setEMailId(user.emailAddress);
if (user.departmentCode !=
null) {
DepartmentDetailType departmentDetailType =
new DepartmentDetailType();
StringListType dcodeList =
new StringListType();
if (user.departmentCode.contains(
",")) {
String[] dclist = user.departmentCode.split(
",");
dcodeList.setItem(dclist);
}
else
if (user.departmentCode.contains(
";")) {
String[] dclist = user.departmentCode.split(
";");
dcodeList.setItem(dclist);
}
else {
dcodeList.addItem(user.departmentCode);
departmentDetailType.setDepartmentCodeList(dcodeList);
userInfo.setDepartment(departmentDetailType);
if (user.copyQuotaEnabled) {
if (user.commonAccountEnable || user.colorAccountEnable
|| user.monoAccountEnable) {
QuotaCategoryType quotaCategoryType =
new QuotaCategoryType();
QuotaType colorquotaType =
new QuotaType();
colorquotaType.setQuota(String
.valueOf(user.leftColorCopyImpression));
QuotaType monoquoQuotaType =
new QuotaType();
monoquoQuotaType.setQuota(String
.valueOf(user.leftMonoCopyImpression));
quotaCategoryType.setTotal(colorquotaType);
quotaCategoryType.setTotal(monoquoQuotaType);
userInfo.setQuota(quotaCategoryType);
StringListType permissionList =
new StringListType();
ArrayList<String> pList =
new ArrayList<>();
if (user.monoCopyFeature) {
permissionList.addItem(
"CopyJob");
if (user.monoPrintFeature) {
permissionList.addItem(
"PrintJob");
if (user.scanFeature) {
permissionList.addItem(
"RemoteScan");
permissionList.addItem(
"StoreToLocalStrorage");
permissionList.addItem(
"SendEmail");
if (user.colorPrintFeature && user.colorCopyFeature) {
permissionList.addItem(
"ColorPrint");
if (user.faxFeature) {
permissionList.addItem(
"FaxTransmission");
permissionList.addItem(
"FaxReceivedPrint");
permissionList.addItem(
"FaxReceivedPrint");
permissionList.addItem(
"PrintManagement");
permissionList.addItem(
"JobOperation");
permissionList.addItem(
"EWBAccess");
userInfo.setPermissionList(permissionList);
String soapConstant =
":49629/OutputManagementService";
String fullUrl =
"http://" + printer.ipAddress + soapConstant;
OutputManagementServiceStub port =
new OutputManagementServiceStub(
fullUrl);
printer.currentUserName = user.userName;
LoginMDS loginMDS =
new LoginMDS();
loginMDS.setMDSUserInfo(userInfo);
try {
LoginMDSResponse mdsResponse = port.loginMDS(loginMDS);
}
catch (RemoteException e) {
logger.error(
"Login failed:" + e.getMessage());
}
catch (jp.co.toshibatec.www.e_studio.outputmanagementservice.EBridgeServiceException e) {
logger.info(
"Login failed from sysprint:" + e);
VUser vUser = ToshibaMFP.getInstance().getUserByName(loginAccount);
if (!printer.gs1020) {
ToshibaMFP.getInstance().httpService.releaseAllJobs(
printer.serialNumber, vUser);
}
else
if (!vUser.mfpDirectPrint) {
if ((vUser.allowSelectLevel && vUser.levelList !=
null && vUser.levelList
.size() >
0)
|| (
null != vUser.projectList && vUser.projectList
.size() >
0)) {
if (
"SVGA".equalsIgnoreCase(screenType)) {
resp.sendRedirect(
"/toshibamfp/svga/projectlist.jsp?userName="
+ loginAccount
+
"&serialNumber="
+ printer.serialNumber);
}
else {
resp.sendRedirect(
"/toshibamfp/wvga/projectlist.jsp?userName="
+ loginAccount
+
"&serialNumber="
+ printer.serialNumber);
}
else {
if (
"SVGA".equalsIgnoreCase(screenType)) {
resp.sendRedirect(
"/toshibamfp/svga/mdsPrintList.jsp?userName="
+ loginAccount
+
"&serialNumber="
+ printer.serialNumber);
}
else {
resp.sendRedirect(
"/toshibamfp/wvga/mdsPrintList.jsp?userName="
+ loginAccount
+
"&serialNumber="
+ printer.serialNumber);
}
else {
logger.info(
"Direct print");
ToshibaMFP.getInstance().httpService.releaseAllJobs(
printer.serialNumber, vUser);
}
else {
if (
"SVGA".equalsIgnoreCase(screenType)) {
resp.sendRedirect(
"/toshibamfp/svga/newcard.jsp?cardId="
+ cardId
+
"&language="
+ MfpConfigure.getInstance().getProperty(
CommonConstant.PARAM_DEFAULT_LANGUAGE)
+
"&screenType=" + screenType +
"&serialNumber="
+ serialNumber);
}
else {
resp.sendRedirect(
"/toshibamfp/wvga/newcard.jsp?cardId="
+ cardId
+
"&language="
+ MfpConfigure.getInstance().getProperty(
CommonConstant.PARAM_DEFAULT_LANGUAGE)
+
"&screenType=" + screenType +
"&serialNumber="
+ serialNumber);
logger.info(
"Login failed from sysprint:" + result);
VPrinter printer = ToshibaMFP.getInstance().getPrinterByIpAddress(
printIp);
String cardId =
null;
if (printer !=
null) {
cardId =
null;
if (printer.currentCardId !=
null) {
PrintWriter out =
null;
cardId = printer.currentCardId;
printer.currentCardId =
null;
try {
out = response.getWriter();
out.print(cardId);
}
catch (Exception e) {
e.printStackTrace();
}
finally {
if (out !=
null) {
out.flush();
out.close();
}
else {
PrintWriter out =
null;
try {
out = response.getWriter();
out.print(cardId);
}
catch (Exception e) {
e.printStackTrace();
}
finally {
if (out !=
null) {
out.flush();
out.close();
}
else {
PrintWriter out =
null;
try {
out = response.getWriter();
out.print(cardId);
}
catch (Exception e) {
e.printStackTrace();
}
finally {
if (out !=
null) {
out.flush();
out.close();
}
else{
window.clearInterval(intervalID);
window.location.href=
"/toshibamfp/wvga/mdsNewCard.jsp?cardId="+data;
public
void unSubscribeUserEvent(VPrinter printer)
throws RemoteException{
try {
AddressListType address =
new AddressListType();
address.setAddress(
new String[]{ToshibaMFP.getInstance().fetchUserEventUrl()});
UserEventNameListType eventList =
new UserEventNameListType();
eventList.addEventName(UserEventNameType.LogIn);
eventList.addEventName(UserEventNameType.LogOut);
eventList.addEventName(UserEventNameType.CardReading);
UnsubscribeUserEvent event =
new UnsubscribeUserEvent();
event.setEventNameList(eventList);
event.setAddressList(address);
this.fetchSoapPort(printer.ipAddress).unsubscribeUserEvent(event, printer.token);
}
catch (EBridgeServiceException e) {
logger.debug(
"No user event registered for unsubscribe");
if(
"ReleaseSelected".equalsIgnoreCase(actionType)){
List<String> jobIdList =
this.parseJobIdList(jobListStr);
if(jobIdList.size() >
0){
ToshibaMFP.getInstance().httpService.releaseJobList(printer, user, jobIdList);
resp.sendRedirect(
"/toshibamfp/"+screenPrefix+
"/printlist.jsp?userName=" + user.userName +
"&serialNumber=" + printer.serialNumber +
"¤tPage=" + currentPage);
}
else
if(
"ReleaseAll".equalsIgnoreCase(actionType)){
ToshibaMFP.getInstance().httpService.releaseAllJobs(serialNumber, user);
resp.sendRedirect(
"/toshibamfp/" + screenPrefix +
"/printlist.jsp?userName=" + user.userName +
"&serialNumber=" + printer.serialNumber);
}
else
if(
"DeleteSelected".equalsIgnoreCase(actionType)){
List<String> jobIdList =
this.parseJobIdList(jobListStr);
ToshibaMFP.getInstance().httpService.cancelJobs(jobIdList);
resp.sendRedirect(
"/toshibamfp/" + screenPrefix +
"/printlist.jsp?userName=" + user.userName +
"&serialNumber=" + printer.serialNumber +
"¤tPage=" + currentPage);
}
else
if(
"DeleteAll".equalsIgnoreCase(actionType)){
List<String> jobIdList =
this.parseJobIdList(jobListStr);
ToshibaMFP.getInstance().httpService.cancelJobs(jobIdList);
resp.sendRedirect(
"/toshibamfp/" + screenPrefix +
"/printlist.jsp?userName=" + user.userName +
"&serialNumber=" + printer.serialNumber);
}
else
if(
"Refresh".equalsIgnoreCase(actionType)){
resp.sendRedirect(
"/toshibamfp/" + screenPrefix +
"/printlist.jsp?userName=" + user.userName +
"&serialNumber=" + printer.serialNumber);
}
else
if(
"View".equalsIgnoreCase(actionType)){
resp.sendRedirect(
"/toshibamfp/" + screenPrefix +
"/mdsViewContent.jsp?require_page=1&job_type=PRINT&job_id=" + jobId +
"¤tPage=" + currentPage +
"&selectJobList=" + jobListStr+
"&userName=" + user.userName +
"&serialNumber=" + printer.serialNumber);
String result=ToshibaMFP.getInstance().httpService.login(login_account,
"", login_password, printer.serialNumber);
if(result!=
null&&result.startsWith(
"OK:")){
VUser user=VUser.assemblyByXml(result.substring(
3));
MDSUserInfoType userInfo=
new MDSUserInfoType();
userInfo.setName(user.userName);
userInfo.setPassword(user.password);
userInfo.setDomain(login_domain);
userInfo.setUserID(user.userId);
if(user.emailAddress!=
null){
userInfo.setEMailId(user.emailAddress);
if(user.departmentCode!=
null){
DepartmentDetailType departmentDetailType=
new DepartmentDetailType();
StringListType dcodeList=
new StringListType();
if(user.departmentCode.contains(
",")){
String [] dclist=user.departmentCode.split(
",");
dcodeList.setItem(dclist);
}
else
if(user.departmentCode.contains(
";")){
String [] dclist=user.departmentCode.split(
";");
dcodeList.setItem(dclist);
}
else{
dcodeList.addItem(user.departmentCode);
departmentDetailType.setDepartmentCodeList(dcodeList);
userInfo.setDepartment(departmentDetailType);
if(user.copyQuotaEnabled){
if(user.commonAccountEnable||user.colorAccountEnable||user.monoAccountEnable){
QuotaCategoryType quotaCategoryType=
new QuotaCategoryType();
QuotaType colorquotaType=
new QuotaType();
colorquotaType.setQuota(String.valueOf(user.leftColorCopyImpression));
QuotaType monoquoQuotaType=
new QuotaType();
monoquoQuotaType.setQuota(String.valueOf(user.leftMonoCopyImpression));
quotaCategoryType.setTotal(colorquotaType);
quotaCategoryType.setTotal(monoquoQuotaType);
userInfo.setQuota(quotaCategoryType);
StringListType permissionList =
new StringListType();
ArrayList<String> pList=
new ArrayList<>();
if(user.monoCopyFeature){
permissionList.addItem(
"CopyJob");
if(user.monoPrintFeature){
permissionList.addItem(
"PrintJob");
if(user.scanFeature){
permissionList.addItem(
"RemoteScan");
permissionList.addItem(
"StoreToLocalStrorage");
permissionList.addItem(
"SendEmail");
if(user.colorPrintFeature&&user.colorCopyFeature){
permissionList.addItem(
"ColorPrint");
if(user.faxFeature){
permissionList.addItem(
"FaxTransmission");
permissionList.addItem(
"FaxReceivedPrint");
permissionList.addItem(
"FaxReceivedPrint");
permissionList.addItem(
"PrintManagement");
permissionList.addItem(
"JobOperation");
permissionList.addItem(
"EWBAccess");
userInfo.setPermissionList(permissionList);
String soapConstant=
":49629/OutputManagementService";
String fullUrl =
"http://" + printIp + soapConstant;
OutputManagementServiceStub port=
new OutputManagementServiceStub(fullUrl);
printer.currentUserName=user.userName;
LoginMDS loginMDS=
new LoginMDS();
loginMDS.setMDSUserInfo(userInfo);
try {
LoginMDSResponse mdsResponse=port.loginMDS(loginMDS);
}
catch (RemoteException e) {
logger.error(
"Login failed:" + e.getMessage());
catch (jp.co.toshibatec.www.e_studio.outputmanagementservice.EBridgeServiceException e) {
logger.info(
"Login failed from sysprint:"+e);
VUser vUser=ToshibaMFP.getInstance().getUserByName(login_account);
if((vUser.allowSelectLevel && vUser.levelList !=
null && vUser.levelList.size() >
0)||(
null!=vUser.projectList&& vUser.projectList.size() >
0)){
if(
"SVGA".equalsIgnoreCase(screenType)){
resp.sendRedirect(
"/toshibamfp/svga/projectlist.jsp?userName="+login_account+
"&serialNumber="+printer.serialNumber);
}
else{
resp.sendRedirect(
"/toshibamfp/wvga/projectlist.jsp?userName="+login_account+
"&serialNumber="+printer.serialNumber);
}
else{
if(
"SVGA".equalsIgnoreCase(screenType)){
resp.sendRedirect(
"/toshibamfp/svga/mdsPrintList.jsp?userName="+login_account+
"&serialNumber="+printer.serialNumber);
}
else{
resp.sendRedirect(
"/toshibamfp/wvga/mdsPrintList.jsp?userName="+login_account+
"&serialNumber="+printer.serialNumber);
}
else{
if(
"SVGA".equalsIgnoreCase(screenType)){
resp.sendRedirect(
"/toshibamfp/svga/toshibaLogin.jsp?userInfoNotCorrect=yes");
}
else{
resp.sendRedirect(
"/toshibamfp/wvga/toshibaLogin.jsp?userInfoNotCorrect=yes");
logger.info(
"Login failed from sysprint:"+result);
String actionType = req.getParameter(
"actionType");
String jobListStr = CommonUtil.convertNull(req.getParameter(
"selectJobList"));
String userName = req.getParameter(
"userName");
String serialNumber = req.getParameter(
"serialNumber");
String currentPage = req.getParameter(
"currentPage");
String jobId = req.getParameter(
"job_id");
VUser user = ToshibaMFP.getInstance().getUserByName(userName);
VPrinter printer = ToshibaMFP.getInstance().getPrinterBySerialNumber(serialNumber);
String screenPrefix =
"wvga";
if(
"SVGA".equalsIgnoreCase(printer.screenType)){
screenPrefix =
"svga";
(
2)若操作类型为Release,则释放所有任务,并根据显示类型重定向到打印列表。
if(
"Release".equalsIgnoreCase(actionType)){
List<String> jobIdList =
new ArrayList<String>();
jobIdList.add(jobId);
ToshibaMFP.getInstance().httpService.releaseJobList(printer, user, jobIdList);
if(jobListStr.contains(
":" + jobId)){
jobListStr = jobListStr.replaceAll(
":" + jobId,
"");
resp.sendRedirect(
"/toshibamfp/" + screenPrefix +
"/printlist.jsp?userName=" + user.userName +
"&serialNumber=" + printer.serialNumber +
"¤tPage=" + currentPage +
"&selectJobList=" + jobListStr);
String screenType=
"WVGA";
login_account=login_account.toUpperCase();
if(displaySize.contains(
"600")){
screenType=
"SVGA";
if(
null!=printer){
printer.screenType=screenType;
String login_account=req.getParameter(
"login_account");
String login_password=req.getParameter(
"login_password");
String login_domain=req.getParameter(
"login_domain");
String printIp=req.getRemoteAddr();
VPrinter printer=ToshibaMFP.getInstance().getPrinterByIpAddress(printIp);
if(
null==printer){
String serialNumber=CommonUtil.getSerialNumberByIp(printIp);
printer=ToshibaMFP.getInstance().getPrinterBySerialNumber(serialNumber);
printer.serialNumber=serialNumber;
if(CommonUtil.isBlank(printer.serialNumber)){
printer.serialNumber=CommonUtil.getSerialNumberByIp(printIp);
if(printer.currentUserName!=
null){
printer.currentUserName=
null;
String printName=req.getHeader(
"X-EWB-ModelName");
String displaySize = req.getHeader(
"X-EWB-DisplaySize");
logger.warn(
"Receive X-EWB-UserName:" + printName +
" X-EWB-DisplaySize:" + displaySize);
if(!ToshibaMFP.getInstance().isInitial){
List<VPrinter>printerList=ToshibaMFP.getInstance().httpService.fetchAllToshibaPrinters();
ToshibaMFP.getInstance().addPrinters(printerList);
ToshibaMFP.getInstance().isInitial=
true;