问题描述
我正在向服务器发送一系列SOAP消息,并捕获SOAP事务的结果。我遇到的问题是我需要执行五个SOAP调用,并且每个调用都需要上一个调用中的一些数据。这导致我创建了一个数据类,该数据类包含可在每次调用后进行修改的Getter和Setter访问的字符串。这段代码对我来说似乎“很臭”,类中发生了很多状态更改,我只是想知道是否有更好的方法可以解决此问题。@H_502_1@
protected SoapBodyParameters soapBodyParameters;
public void release(String primaryConfigurationIdentifier) throws ReleaseManagerException {
this.soapBodyParameters.setPrimaryConfigurationItemIdentifier(primaryConfigurationIdentifier);
// Implemented by child - Will throw an exception if bad configuration
verify();
// Get user full name and append soapBodyParameters
String userFullName = sendGetUserInfoSoapMessage(this.soapBodyParameters);
this.soapBodyParameters.setUserFullName(userFullName);
// Create a release package on the server - no return needed
sendCreateReleasePackageFromLocalFilesSoapMessage(this.soapBodyParameters);
// Find the release package ID we just made and append soapBodyParameters
String releasePackageSystemId = sendGetReleasePackagesSoapMessage(this.soapBodyParameters);
this.soapBodyParameters.setReleasePackageSystemId(releasePackageSystemId);
// Open the release package and find the task model @R_897_4045@ion
TaskModel taskModel = sendOpenReleasePackageSoapMessage(this.soapBodyParameters);
this.soapBodyParameter.setTaskModelFile(taskModel.getIARTaskModel());
this.soapBodyParameters.setTaskModelId(taskModel.getTaskModelId());
// Implemented by child - Update the task model with required info
updateLocalTaskModel(this.soapBodyParameters);
// Save the task model to the release package on the server
sendSaveTaskModelSoapMessage(this.soapBodyParameters);
}
因此,每一次这些调用都修改了soapBodyParameters,而随后的每个调用都依赖于上一个调用来修改soapBodyParameters...。我不知道,这只是感觉很臭。就像我在类中伪造一个全局参数一样。@H_502_1@
有更好的方法吗?我正在尝试更好地识别何时何地设计模式更合适。@H_502_1@
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)