Skip to Content

Requrements

In my current project I had to integrate Java applications with SAP System.  One of the requirements was to provide the integration for those places where there was not a direct connection with XI.  The best solution for us was to use email.

     

Thus we had one email, POP3/SMTP protocol and about 30 interfaces.

 

Solutions

There are 2 solutions:

      

  • To use common interface as Mail sender and to deal with adapter module and/or BPM.
  •   

  • To use XIALL protocol of Mail sender adapter and produce XI Message (SOAP with attachment) in Java Application.

The first solution seems to be more complicated for supporting on the XI side. Therefore we have decided to try to follow by the second.

So the  lightweight framework has been created.  It produces XI Messages and supports SMTP and HTTP protocols.  HTTP transport has been used for testing purposes.  Using of the common interface for transport implementation makes possible to add supporting of any protocol.

Let’s throw light on this framework.

Use cases

Framework requires JDK 5.0 and can work on any application server or thick client application. Framework supports attachments and system acknowledgement. In a simple cases when the message storage and application acknowledgment aren’t mandatory  the client Java proxy is a heavyweight solution and could be replaced by this framework. Current version doesn’t support ExactlyOnceInOrder quality of service. 

Possible scenarios:

      

  • Java application sends a message by HTTP directly to the Integration Engine.
  •   

  • Java application sends a message by SMTP. Mail sender adapter picks up message and send it to the Integration Engine.
  •   

  • It is possbile to run this framework as a console application and to send a message directly         to the Integration Engine and to use it instead of Test Message tab in Runtime Workbench. The payload must be stored in the file.         All necessary information(interface, business system and so on) must be stored in the properties file(see readme file in archive).  

The source code and binaries with all libraries can be downloaded from here.

Architecture

UML diagram for the basic interfaces is presented below.

image
image

 

How to use

Below is the sample that shows how to send a message.

MessageInterface mi = new MessageInterfaceImpl("InvoiceCreated_Out", "http://server.com/Project");
Message message = new MessageImpl("SYSTEM", mi);

// By default QualityOfService is ExactlyOnce.
message.setMode(Message.BEST_EFFORT);

Payload payload = new PayloadImpl();
StringReader reader = new StringReader("");
StreamSource source = new StreamSource(reader);
payload.setContent(source);
payload.setCharset("UTF-8");
message.setPayload(payload);

AttachmentPart attachment = new AttachmentPartImpl();
attachment.setContent("Test", "text/plain");
attachment.setCharset("UTF-8");
message.addAttachmentPart(attachment);

// Send a message by SMTP
TransportConfiguration configuration = new TransportConfiguration();

MailEndpoint mailEndpoint = new MailEndpoint("25", "smtpserver", "username", "password");
mailEndpoint.setFrom("xi@server.com");
mailEndpoint.setSubject("Test");
mailEndpoint.setTo("xi@server.com");

Transport mailTransport = configuration.getMailTransport(mailEndpoint);

mailTransport.sendAsync(message);

// Send a message by HTTP
HTTPEndpoint httpEndpoint = new HTTPEndpointImpl("8000", "xiserver", "xiuser", "xipassword");
Transport httpTransport = configuration.getHTTPTransport(httpEndpoint);
Message replyMessage = httpTransport.sendSync(message);
if (replyMessage.isAcknowledgement()) {
    // This message was sent asynchronously
    String status = replyMessage.getAckStatus();
} else {
    // This message was sent synchronously
    StreamSource response = replyMessage.getPayload().getContent();
}

  

Conclusion

  This framework is experimental and certainly is not intended to replace Java Proxy. 

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply