WEB开发网
开发学院WEB开发Jsp J2EE Web服务客户端质量报告(四) 阅读

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

 2008-01-05 08:20:49 来源:WEB开发网   
核心提示:客户端服务软件包通过指引WSDL编译器到应用服务器提供的WSDL上可自动生成客户端服务软件包,这个软件包包含许多类,J2EE Web服务客户端质量报告(四),我们需要修改的唯一类就是客户端Stub类,同样地, 服务Stub类的名称为 <ServiceName>ServantInterface_Stub,其中<Servi
客户端服务软件包

  通过指引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()之前立即添加了下面的单行:


Tags:JEE Web 服务

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接