服務器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()上: