此内容没有您所选择的语言版本。

7.5. Construct the Client


Procedure 7.2. Task

  • As soon as we have the Message definitions supported by the service, we can construct the client code. The business logic used to support the service is never exposed directly by the service (that would break one of the important principles of SOA: encapsulation). This is essentially the inverse of the service code:
    		  ServiceInvoker flightService = new ServiceInvoker(...);
    Message request = // create new Message of desired type
    
    request.getBody().add(“org.example.flight.seatnumber”, ”1”);
    request.getBody().add(“ org.example.flight.flightnumber”, “BA1234”);
    
    request.getHeader().getCall().setMessageID(1234);
    request.getHeader().getCall().setReplyTo(myEPR);
    
    Message response = null;
    
    do
    {
    	response = flightService.deliverSync(request, 1000);
    	
    	if (response.getHeader().getCall().getRelatesTo() == 1234)
    	{
    	// it's out response!
    	
    	break;
    	}
    	else
    	response = null;  // and keep looping
    	
    } while !maximumRetriesExceeded();
    
    Copy to Clipboard Toggle word wrap

    Note

    Much of the above will be recognizable to readers who have worked with traditional client/server stub generators. In those systems, the low-level details (such as the opcodes and the parameters) are hidden behind higher-level stub abstractions. SOA Platform has integration with RESTEasy that enables a user to develop annotation based REST style web services. These hide the low level details such as opcodes and parameters.

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat