J2EE Web处事客户端质量陈诉(二)
处事器Web 处事软件包
处事器Web 处事软件包可自动生成。在Sun ONE Studio中,Web模块的建设只要选择一组EJB Java要领即可,而且Web处事软件包的类可由Web模块建设。
该软件包包括很多类和接口。这里最要害的一个就是<ServiceName>ServantInterface_Tie 类,在这个类中处事名就是<ServiceName> 。类Tie是Web处事模块最上面的仓库;它将引入的处事挪用绑定到建设它的EJB组件上。我们只需修改类Tie就可以添加次数记载。
Tie包罗很多要领,可是我们只需修改与EJB贸易要领invoke_<X>关联的那一个要领。在要领invoke_<X>中,<X>暗示EJB贸易要领的名称。我们添加一个 import Payload.*; 到类 Tie上,并对每个贸易要领作了一个小小的修改。让我们看看下面的要领 invoke_SubmitWork() :
/*
* This method does the actual method invocation for operation: SubmitWork
*/
private void invoke_SubmitWork(StreamingHandlerState state) throws Exception {
TransactionService.XactServiceGenServer.
XactServiceServantInterface_SubmitWork_RequestStruct
myXactServiceServantInterface_SubmitWork_RequestStruct = null;
Object myXactServiceServantInterface_SubmitWork_RequestStructObj =
state.getRequest().getBody().getValue();
/* Line added to generated method: */
Serializer.queueFirstAttachmentText(state.getMessageContext());
if (myXactServiceServantInterface_SubmitWork_RequestStructObj
instanceof SOAPDeserializationState) {
myXactServiceServantInterface_SubmitWork_RequestStruct =
(TransactionService.XactServiceGenServer.
XactServiceServantInterface_SubmitWork_RequestStruct)
((SOAPDeserializationState)
myXactServiceServantInterface_SubmitWork_RequestStructObj)
.getInstance();
} else {
myXactServiceServantInterface_SubmitWork_RequestStruct =
(TransactionService.XactServiceGenServer.
XactServiceServantInterface_SubmitWork_RequestStruct)
myXactServiceServantInterface_SubmitWork_RequestStructObj;
}
java.lang.String result =
((TransactionService.XactServiceGenServer.XactServiceServantInterface)
getTarget()).SubmitWork
(myXactServiceServantInterface_SubmitWork_RequestStruct.getString_1());
TransactionService.XactServiceGenServer.
XactServiceServantInterface_SubmitWork_ResponseStruct
myXactServiceServantInterface_SubmitWork_ResponseStruct =
new TransactionService.XactServiceGenServer
.XactServiceServantInterface_SubmitWork_ResponseStruct();
SOAPHeaderBlockInfo headerInfo;
myXactServiceServantInterface_SubmitWork_ResponseStruct.setResult(result);
SOAPBlockInfo bodyBlock = new SOAPBlockInfo
(ns1_SubmitWork_SubmitWorkResponse_QNAME);
bodyBlock.setValue(myXactServiceServantInterface_SubmitWork_ResponseStruct);
bodyBlock.setSerializer
(myXactServiceServantInterface_SubmitWork_ResponseStruct_SOAPSerializer);
state.getResponse().setBody(bodyBlock);
}
我们添加了一个单行到invoke_SubmitWork()上:
Serializer.queueFirstAttachmentText(state.getMessageContext());
getMessageContext()返回实现接口javax.xml.rpc.handler.soap.SOAPMessageContext 的工具。该工具提供对当前SOAP信息的会见。我们通报实现接口SOAPMessageContext 的工具到Payload.Serializer中的一个静态要领上。该静态要领从第一个信息附件中获取XML字符串并将它列队期待次数处理惩罚器EJB组件的挪用。
我们对每个invoke_<X>要领作了同样的修改。