Development Utilities
Using the Error Utility
The wm.b2b.cxml.utils.errors folder of the WmAribaSupplier package provides a set of APIs for reporting errors in Ariba Supplier OnRamp Adapter. The core of this package relies on a serviceError structure in the pipeline to detect and process errors. When developing services, make sure that you return a serviceError structure containing an error message if you want to report errors to the Ariba Supplier OnRamp Adapter core.
To create a serviceError record, invoke wm.b2b.cxml.utils.errors:setError with the following arguments:
- error. The error message.
- errorStatusCode. Optional. This argument corresponds to the numeric status code in the cXML ErrorResponse returned to Ariba Supplier Network. If not specified, the ErrorResponse statusCode is set to 500. Otherwise, the value you specify here is used. For a description of ErrorResponse status codes, see the cXML User's Guide Version 1.2.
Using the Persistence Utility
If your shopping cart system cannot store the buyer session metadata that is needed for the punchout ordering process, you can save the buyer session data by passing the data fields as GET input fields in all the catalog pages returned to the buyer, or as hidden form fields embedded in all the catalog pages returned to the buyer. However, keep in mind that these fields need to be passed in every catalog page until the buyer checks out.
Storing Data in the webMethods Server Session Object
If you need to store the shopping cart data, you can use the services in the wm.b2b.cxml.utils.persistence folder of the WmAribaSupplier package. The wm.b2b.cxml.utils.persistence.session folder uses the session object of Integration Server to store the session data persistently in Integration Server.
Storing Data in External Data Stores
About this task
To store the buyer session metadata persistently in an external data store, you must implement services to create, read, and delete the buyer session metadata into the external persistent store. These services should implement the service specifications of saveBuyerSessionDataSpec, getBuyerSessionDataSpec, and removeBuyerSessionDataSpec described in wm.b2b.cxml.utils.persistence.spec.
To store metadata in the Integration Server session object
Procedure
Using the Attachment Utility
Ariba SN is capable of sending cXML OrderRequest and attachment documents in a MIME/Multipart message. Ariba Supplier OnRamp Adapter is capable of receiving MIME/Multipart messages containing OrderRequests and attachments. It extracts the attachments and for each attachment and creates an attachmentWrapper data object to represent the attachment.
Each attachmentWrapper contains metadata describing the attachment document and the contents of the attachments in bytes.
The set of attachments are collected in an attachmentWrapperCollection object which allows you to:
- Loop through the set of attachmentWrappers.
- Retrieve an attachmentWrapper by index.
- Retrieve an attachmentWrapper by the attachment's unique identifier. Each attachment sent by Ariba SN has a unique ID and is set in the cXML OrderRequest. They are located in the element cXML/Request/OrderRequest/OrderRequestHeader/Comment.
Working with the attachmentWrapperCollection Object
The attachmentWrapperCollection object will appear in your OrderRequest handler service pipeline. You use the services in the pub.ariba.supplier.attachment.collection folder to manipulate the attachmentWrapperCollection. For a detailed description of these services, see pub.ariba.supplier.attachment.collection.
To Get the Number of Attachments in the Collection
Use the service pub.ariba.supplier.attachment.collection:getCollectionSize.
To Get a Specific attachmentWrapper from the Collection
If you want to retrieve the attachmentWrapper at a particular index, set the index input field to the index of the item you want to retrieve (the first attachmentWrapper is at index=0).
To Retrieve the attachmentWrapper from the Collection by ID
You can also retrieve the attachmentWrapper by ID. Each attachment has a unique identifier. All
attachments sent by Ariba SN have a unique ID and are set in the cXML OrderRequest. They are located in the element
cXML/Request/OrderRequest/OrderRequestHeader/Comments/Attachment/URL as the string "cid: <
unique attachment id
>".
Use the service pub.ariba.supplier.attachment:getIDFromComment to extract the attachment ID from the Comments/Attachment record entry corresponding to the attachment you are interested in.
Invoke pub.ariba.supplier.attachment.collection:getWrapperFromCollection with the id field set to the extracted value.
To Loop Through the attachmentWrapperCollection
You can either loop through all the attachmentWrappers in a collection in either of the following ways:
- Use the pub.ariba.supplier.attachment.collection:getWrapperList service.
This service will return a list of attachmentWrapper objects. You can use the flow loop construct to loop through each element. This service is resource intensive. It should only be used for small number of attachments.
Set the sortOrder input parameter to forward to sort the list of attachmentWrappers first to last, or set it to backward to sort them last to first.
- Use the attachmentWrapperCollectionIteratorservice to iterate through the
attachmentWrapper elements.
Using the iterator is much more efficient than using the getWrapperList. To use the collection iterator, invoke the service pub.ariba.supplier.attachment.collection.iterator:getIterator to get an iterator object for the collection.
Set the direction input parameter to forward to iterate through the list of attachmentWrappers first to last, or set it to reverse to sort them last to first.
Once you have the collectionIterator object, use the getIterator and iteratorHasMoreWrappers services in a repeat flow statement as follows.
INVOKE pub.ariba.supplier.attachment.collection.iterator:getIterator REPEAT (repeat-on SUCCESS) INVOKE pub.ariba.supplier.attachment.collection.iterator:iteratorHasMoreWrappers BRANCH on hasMoreWrappers SEQUENCE true INVOKE pub.ariba.supplier.attachment.collection.iterator:getNextWrapperFromIterator <do something with the attachment wrapper> SEQUENCE false EXIT $loop
Working with the attachmentWrapper Object
Once you have an attachmentWrapper, you can get the attachment's metadata as described in the record pub.ariba.supplier.attachment:AttachmentInfo, or you can get the attachment's contents in bytes.
- To get the attachment metadata information, invoke the service pub.ariba.supplier.attachment:getInfoFromWrapper.
- To get the attachment's contents, invoke the service pub.ariba.supplier.attachment:getContentFromWrapper.
Set the format input parameter to bytes if you want the contents in bytes, or set it to string if you want the contents in string format.