Introduction
This article explains about processing the transaction using the AS4 protocol.
Audience
It is assumed that readers of this article know how to setup a B2B enterprise profile, partner on webMethods.io B2B platform, and create a flow service.
Pre-requisite
•	Set up B2B enterprise profile, partner profile, Business Document and TPA.
•	Flow service to send and receive the AS4 message.
Topics Covered
- Develop flow service to send and receive the message using AS4 protocol in webmethods.io integration using One-Way/Push mechanism
- End to End working flow.
Usecase Flow Diagram
Step 1: The initiating MSH sends the data packaged as a user message to the responding MSH.
Step 2: The responding MSH receives and processes the user message.
Usecase
•	In our use case we have 2 tenants one tenant from where we will submit the transactions and another tenant which will receive the transaction.
•	In our use case in webmethods.io B2B Sender is “Silver Brew Enterprises” and Receiver is “Agile Software”
•	We will submit the  Shipment order xml (Purchase order xml) message from webMethods.io integration using the B2B operation.
•	The message is received at the receiver b2b side and then the message is given to webMethods.io Integration for further processing.
What is AS4 protocol?
•	AS4 (Applicability Statement 4) is an open standard for the secure and payload-agnostic exchange of Business-to-business documents using Web services.
•	 Secure document exchange is governed by aspects of WS-Security, including XML Encryption and XML Digital Signatures.
•	 Payload agnosticism refers to the document type (e.g. purchase order, invoice, etc.) not being tied to any defined SOAP action or operation.
For more details please refer: AS4 - Wikipedia
Message exchange patterns in AS4
AS4 supports the following ebMS MEPs for both the sender and the receiver:
•	One-Way/Push: Sends a user message to a trading partner.
•	One-Way/Pull: Sends a pull signal to a trading partner to receive a user message.
•	Two-Way/Sync: Synchronously exchanges messages between two trading partners.
•	Two-Way/PushPull: Pushes a request user message to a trading partner and uses a pull signal to receive a reply user message.
•	Two-Way/PushPush: Asynchronously exchanges messages between two trading partners.
For more details please refer: Working with Trading Partner Agreements - webMethods.io B2B
•	Configuration for source tenant
Enterprise Profile
Partner Profile
Outbound Channel for AS4 Protocol
Configure trading partner agreement
- AS4 protocol, all the configuration, and details are configured at the TPA level.
- It has become quite critical we configure the TPA with all mandatory details. During run time all the configurations are referred from TPA only.
- Attached is the TPA zip file for reference.
SourceTenantTPAExport.zip (2.9 KB)
Configuration for Destination tenant
Enterprise Profile
Partner Profile
Create Inbound AS4 channel
Create a Custom XML document
•	Created the custom shipment order XML document.
•	After importing it, promote the attributes to identify the sender and receiver.
Create a Processing rule to process the received message
Assets developed on webMethods.io Integration layer
Source tenant
- Developed asset to submit the message from webMethods.io Integration flow service to webMethods.io B2B.
- In our case we have developed the flowservice ”SubmitAS4Message”.
•	Attached is the flowservice for the same.
SubmitAS4Message.zip (9.6 KB)
Destination tenant
- 
Developed asset to receive the message from webMethods.io B2B. 
- 
In our case we have developed the flow service “RcvDataFromB2B”. 
- 
This will receive the data from B2B and parse it.
 
 
- 
Attached is the flow service for the same. 
RcvDataFromB2B.zip (9.6 KB)
Note:
- In our case we have set extract attachment as true in the TPA. Therefore we can receive and parse the actual data directly.
- If we have not set the parameter to true, then we need to use getContentParts operation to extract the message.
End-to-End Testing
- Submit the message to B2B from flow service “SubmitAS4Message”.
 
- Transaction on B2B source tenant.
 
- Transaction received on destination B2B tenant.
 
 
 
Transaction received webMethods.io Integration
Assets Developed
Source Tenant.
FlowService: SubmitAS4Message
SubmitAS4Message.zip (9.6 KB)
B2B Assets
Destination Tenant.
FlowService: RcvMessageFromB2B
RcvDataFromB2B.zip (9.6 KB)
B2B Assets
#tutorial#webMethods#webMethods-cloud#webMethods-io-B2B#webMethods-io-Integration#B2B-Integration