J2EE Web服务客户端质量报告(四)[Java编程]
本文“J2EE Web服务客户端质量报告(四)[Java编程]”是由七道奇为您精心收集,来源于网络转载,文章版权归文章作者所有,本站不对其观点以及内容做任何评价,请读者自行判断,以下是其具体内容:
客户端服务软件包
通过指引WSDL编译器到利用服务器供应的WSDL上可自动生成客户端服务软件包.这个软件包包含很多类.我们需求改正的唯一类就是客户端Stub类.一样地,服务器Web 服务软件包也包含类Tie,它可将Web服务恳求绑定到EJB办法上,客户端Stub类为每个服务商业办法的每个客户端装备一个办法.
服务Stub类的名称为 <ServiceName>ServantInterface_Stub,此中<ServiceName>就是服务名.我们看看类XactServiceServantInterface_Stub 内的submitWork()办法:
/*
* Implementation of submitWork
*/
public java.lang.String submitWork(java.lang.String string_1)
throws java.rmi.RemoteException {
try {
StreamingSenderState _state = _start(_handlerChain);
InternalSOAPMessage _request = _state.getRequest();
_request.setOperationCode(SubmitWork_OPCODE);
Xact.XactServiceServantInterface_SubmitWork_RequestStruct
_myXactServiceServantInterface_SubmitWork_RequestStruct =new Xact.XactServiceServantInterface_SubmitWork_RequestStruct();
_myXactServiceServantInterface_SubmitWork_RequestStruct.setString_1(string_1);
SOAPBlockInfo _bodyBlock = new SOAPBlockInfo(ns1_SubmitWork_SubmitWork_QNAME);
_bodyBlock.setValue(_myXactServiceServantInterface_SubmitWork_RequestStruct);
_bodyBlock.setSerializer(myXactServiceServantInterface_SubmitWork_RequestStruct_SOAPSerializer);
_request.setBody(_bodyBlock);
_state.getMessageContext().setProperty(HttpClientTransport.HTTP_SOAPACTION_PROPERTY, "");
Serializer.attachPendingReportToMessage(_state.getMessageContext());
_send((String) _getProperty(ENDPOINT_ADDRESS_PROPERTY), _state);
Xact.XactServiceServantInterface_SubmitWork_ResponseStruct
_myXactServiceServantInterface_SubmitWork_ResponseStruct = null;
Object _responseObj = _state.getResponse().getBody().getValue();
if (_responseObj instanceof SOAPDeserializationState) {
_myXactServiceServantInterface_SubmitWork_ResponseStruct =
(Xact.XactServiceServantInterface_SubmitWork_ResponseStruct)
((SOAPDeserializationState)_responseObj).getInstance();
} else {
_myXactServiceServantInterface_SubmitWork_ResponseStruct =(Xact.XactServiceServantInterface_SubmitWork_ResponseStruct)responseObj;
}
return _myXactServiceServantInterface_SubmitWork_ResponseStruct
.getResult();
} catch (RemoteException e) {
// Let this one through unchanged
throw e;
} catch (JAXRPCException e) {
throw new RemoteException(e.getMessage(), e);
} catch (Exception e) {
if (e instanceof RuntimeException) {
throw (RuntimeException)e;
} else {
throw new RemoteException(e.getMessage(), e);
}
}
}
在上述的代码中,我们在_send()之前当即增添了下面的单行:
Serializer.attachPendingReportToMessage(_state.getMessageContext());
假如没有待办理的客户端报告需求发送,attachPendingReportToMessage 就返回.不然,它将当前报告连在XML之后并将它当作文本附件增添到SOAP信息中.我们对其他的商业办法也作了一样的改正,在它们的每个_send()调用之前当即增添了上面的代码行.
以上是“J2EE Web服务客户端质量报告(四)[Java编程]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
本文地址: | 与您的QQ/BBS好友分享! |