首页 > 学院 > 开发设计 > 正文

J2EE Web服务客户端质量报告(二)

2019-11-17 06:16:10
字体:
来源:转载
供稿:网友

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


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表