RESTifying Procurement – Service Running

Though not much yet, I have put the procurement service online. At the moment, the service for the supplier party of the UBL business process is provided by the implementation. It can be accessed at http://labs.nordsc.com:8080/rp/supplier/service.

$ curl http://labs.nordsc.com:8080/rp/supplier/service | tidy -xml -i -q
 
<service xmlns="http://www.w3.org/2007/app"
xmlns:atom="http://www.w3.org/2005/Atom">
  <workspace>
    <atom:title type="text">This service implements the UBL
    supplier role.</atom:title>
    <atom:link rel="common-catalogue"
    href="http://labs.nordsc.com:8080/rp/supplier/provider/common-catalogue"
    type="application/procurement+xml;type=catalogue"
    title="The public catalogue"></atom:link>
  </workspace>
</service>

The service document provides a link to the common catalogue provided by the provider role (here played by the supplier party). I explain the special use I make of AtomPub service documents in this post.

A client that understands the ‘common-catalogue’ link relation and intends to look at the common catalogue can now do this:

$ curl http://labs.nordsc.com:8080/rp/supplier/provider/common-catalogue | tidy -xml -i -q
 
<?xml version='1.0' encoding='utf-8'?>
<?xml-stylesheet href='http://labs.nordsc.com:8080/rp/css/catalogue.css' type='text/css'?>
<Catalog xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
xmlns="urn:oasis:names:specification:ubl:schema:xsd:Catalogue-2">
  <cbc:ID>public-001</cbc:ID>
  <cbc:IssueDate>2012-02-02</cbc:IssueDate>
  <cac:CatalogueLine>
    <cbc:ID>1</cbc:ID>
    <cac:RequiredItemLocationQuantity>
      <cac:Price>
        <cbc:PriceAmount currencyID="EUR">16.90</cbc:PriceAmount>
      </cac:Price>
    </cac:RequiredItemLocationQuantity>
    <cac:Item>
      <cbc:Name>Valve 1-54</cbc:Name>
      <cbc:Description>This valve helps with a lot of
      things</cbc:Description>
      <cac:SellersItemIdentification>
        <cbc:ID schemeURI="http://labs.nordsc.com/schemes/items/"
        schemeDataURI="http://labs.nordsc.com:8080/rp//provider/items/">
        PARTS-7615221</cbc:ID>
      </cac:SellersItemIdentification>
    </cac:Item>
  </cac:CatalogueLine>
<cac:CatalogueLine>
    <cbc:ID>2</cbc:ID>
    <cac:RequiredItemLocationQuantity>
      <cac:Price>
        <cbc:PriceAmount currencyID="EUR">26.90</cbc:PriceAmount>
      </cac:Price>
    </cac:RequiredItemLocationQuantity>
    <cac:Item>
      <cbc:Name>Valve 2-54</cbc:Name>
      <cbc:Description>This valve helps with a lot of
      things</cbc:Description>
      <cac:SellersItemIdentification>
        <cbc:ID schemeURI="http://labs.nordsc.com/schemes/items/"
        schemeDataURI="http://labs.nordsc.com:8080/rp//provider/items/">
        PARTS-7625222</cbc:ID>
      </cac:SellersItemIdentification>
    </cac:Item>
  </cac:CatalogueLine>
  <cac:CatalogueLine>
    <cbc:ID>3</cbc:ID>
    <cac:RequiredItemLocationQuantity>
      <cac:Price>
        <cbc:PriceAmount currencyID="EUR">36.90</cbc:PriceAmount>
      </cac:Price>
    </cac:RequiredItemLocationQuantity>
    <cac:Item>
      <cbc:Name>Valve 3-54</cbc:Name>
      <cbc:Description>This valve helps with a lot of
      things</cbc:Description>
      <cac:SellersItemIdentification>
        <cbc:ID schemeURI="http://labs.nordsc.com/schemes/items/"
        schemeDataURI="http://labs.nordsc.com:8080/rp//provider/items/">
        PARTS-7635223</cbc:ID>
      </cac:SellersItemIdentification>
    </cac:Item>
  </cac:CatalogueLine>
</Catalog>

According to the to-be-written processing intent of application/procurement+xml a client could now select items from the catalogue and create an order from them. How that order looks and – more interesting – where to send that order will be the subject of one of the next posts.

The implementation will serve the examples as application/xml to browsers thanks to Jersey’s conneg support so you won’t get an annoying download. There is also CSS styling of the XML so you can actually see something.

Leave a Reply