Child pages
  • Generic Web Services Guidelines
Skip to end of metadata
Go to start of metadata

Modified on 2011-02-08 16:40 by Administrator

1. Introduction

This document provides guidelines for producing and consuming web services among companies in the agriculture industry. It includes a sample Web Services Description Language (WSDL) document that is designed to support business document exchange (in contrast to fine-grained operation invocations.)

2. Key Words Used to Indicate Requirement Levels

Key words used to indicate requirements levels are defined at http://www.ietf.org/rfc/rfc2119.txt.

Per the reference:

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

2.1 Transport and Security Protocols

HTTPS MUST be used for all Web service interactions. The Web Services Security: UsernameToken Profile 1.1 OASIS Standard Specification, 1 February 2006 must be used for identity and authentication. It may be found at http://www.oasis-open.org/committees/download.php/16782/wss-v1.1-spec-os-UsernameTokenProfile.pdf.

The WS-I Basic Security Profile 1.1 provides examples that may be useful to implementers. It is available at http://www.ws-i.org/Profiles/BasicSecurityProfile-1.1.html.

The following WSDL will serve as the basis for discussion throughout the remainder of this document.

2.2 Sample WSDL with Parameters

<?xml version="1.0" encoding="UTF-8"?>
<definitions name="AgGatewayDocumentExchange" targetNamespace="urn:aggateway:names:ws:docexchange"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="urn:aggateway:names:ws:docexchange"
  xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
  xmlns="http://schemas.xmlsoap.org/wsdl/">
  <wsp:UsingPolicy xmlns:n1="http://schemas.xmlsoap.org/wsdl/" n1:Required="false"/>
  <wsdl:types>
    <xsd:schema xmlns="urn:aggateway:names:ws:docexchange"
      xmlns:tns="urn:aggateway:names:ws:docexchange" attributeFormDefault="unqualified"
      elementFormDefault="qualified" targetNamespace="urn:aggateway:names:ws:docexchange">
      <xsd:element name="inboundData" type="inboundData"/>
      <xsd:complexType name="inboundData">
        <xsd:sequence>
          <!-- Identifies the business process -->
          <xsd:element minOccurs="0" name="businessProcess" type="aggatewayToken"/>
          <!-- Identifies the business process step -->
          <xsd:element minOccurs="0" name="processStep" type="aggatewayToken"/>
          <!-- Identifies the client -->
          <xsd:element minOccurs="0" name="partnerId" type="aggatewayToken"/>
          <!-- The partner Id qualifier. -->
          <xsd:element minOccurs="0" name="partnerType" type="aggatewayToken"/>
          <!-- Identifies the business process instance -->
          <xsd:element minOccurs="0" name="conversationId" type="aggatewayToken"/>
          <!-- Identifies the message (must be globally unique) -->
          <xsd:element minOccurs="0" name="messageId" type="aggatewayToken"/>
          <!-- The business document provided as the request -->
          <xsd:element minOccurs="1" name="xmlPayload" type="xmlPayload"/>
        </xsd:sequence>
      </xsd:complexType>
      <xsd:element name="outboundData" type="outboundData"/>
      <xsd:complexType name="outboundData">
        <xsd:sequence>
          <!-- Identifies the business process step -->
          <xsd:element minOccurs="0" name="processStep" type="aggatewayToken"/>
          <!-- Identifies the message (must be globally unique) -->
          <xsd:element minOccurs="0" name="messageId" type="aggatewayToken"/>
          <!-- The business document provided as the response -->
          <xsd:element minOccurs="0" name="xmlPayload" type="xmlPayload" maxOccurs="unbounded"/>
        </xsd:sequence>
      </xsd:complexType>
      <xsd:simpleType name="aggatewayToken">
        <xsd:restriction base="xsd:token">
          <xsd:pattern value="[a-zA-Z0-9_\-:\.]{0,128}"/>
        </xsd:restriction>
      </xsd:simpleType>
      <xsd:complexType name="xmlPayload">
        <xsd:sequence>
          <xsd:any namespace="##any" processContents="lax"/>
        </xsd:sequence>
      </xsd:complexType>
    </xsd:schema>
  </wsdl:types>
  <message name="DocExchangeInput">
    <part name="parameters" element="tns:inboundData"/>
  </message>
  <message name="DocExchangeOutput">
    <part name="result" type="tns:outboundData"/>
  </message>
  <message name="DocExchangeFault">
    <part name="problem" type="xsd:string"/>
  </message>
  <portType name="DocExchangePortType">
    <operation name="execute">
      <input message="tns:DocExchangeInput"/>
      <output message="tns:DocExchangeOutput"/>
      <fault name="DocExchangeProblem" message="tns:DocExchangeFault"/>
    </operation>
  </portType>
  <binding name="DocExchangeBinding" type="tns:DocExchangePortType">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <operation name="execute">
      <soap:operation soapAction="execute"/>
      <input>
        <soap:body use="literal"/>
        <wsp:Policy>
          <wsp:PolicyReference URI="policy:userNameTokenPolicy"/>
        </wsp:Policy>
      </input>
      <output>
        <soap:body use="literal"/>
      </output>
      <fault name="DocExchangeProblem">
        <soap:fault name="DocExchangeProblem" use="literal"/>
      </fault>
    </operation>
  </binding>
  <service name="AgGatewayDocumentExchange">
    <port name="AgGatewayDocumentExchangePort" binding="tns:DocExchangeBinding">
      <soap:address location="http://www.aggateway.org/samples/ws/AgGatewayDocumentExchange_1.0"/>
    </port>
  </service>
</definitions>

2.3 Definitions

For the purposes of discussion in this specification, the following terms are defined:

AUBTP: is an acronym for agreed upon by trading partners. This refers to two or more trading partners agreeing to a more specific use of some aspect of an eBusiness standard or guideline—an aspect that, by definition, would be more generically defined.

client: a trading partner invoking a web service

metadata elements: refers to all child elements of the inboundData and outboundData elements other than the xmlPayload element, which includes the following elements: businessProcess, processStep, partnerId, partnerType, conversationId, and messageId.

protocol: the supported values, semantics, and usage patterns of the metadata elements AUBTP

request: an HTTPS request

response: an HTTPS response to a request or where a ppropriate a TechnicalAck.

service provider: a trading partner providing web services

TechnicalAck: a message sent back to the client to acknowledge the receipt of a request.

2.4 Specification for AgGateway Services

The AgGateway WSDL metadata elements are intended to support a messaging architecture where the routing/transport responsibilities may be separated from the business processing responsibilities. This enables a message to be routed without inspecting the payload.

The supported values, semantics, and usage patterns for metadata elements are ultimately determined by trading-partner pairs engaged in eBusiness. Trading-partner pairs will often agree to use values, semantics, and usage patterns established by a group representing an industry sector (e.g., seed, feed, ornamental horticulture.)

2.5 Usage Definition of “inboundData” Elements (i.e., Request)

2.5.1 businessProcess

businessProcess identifies the business process associated with the xmlPayload element content. Multiple messages may be required to complete a particular businessProcess, in which case the processStep may be used to specify the message type. However, a processStep MAY not be defined when the business process definition contains only one process step, AUBTP. The businessProcess values defined by AgGateway MUST be defined such that there is a one-to-one identifier-to-process definition correspondence.

2.5.2 processStep

processStep identifies the business process step associated xmlPayload element content. If a processStep element is present then a businessProcess element must be present as well.

The function of some web services is simply for a client to post a message to a service provider with only success/failure indication in a response. In such situations it is RECOMMENDED that the processStep value in the response be either be a TechnicalAck or some equivalent.

2.5.3 partnerId

partnerId identifies the partner sending the request. If a partnerId element is present then a partnerType element MUST be present as well.

It is RECOMMENDED that this identify the physical sender. If a business partner were using a service bureau to send messages, for example, the partnerId would identify the service bureau rather than the business partner. For business partners handling their own communications, of course, the physical sender and the business partner would be one and the same.

2.5.4 PartnerType

partnerType indicates the partnerId identifier. The value MUST be taken from the Ag eStandards cidxListPartnerAgencyAttribute type definition.

2.5.5 conversationId

conversationId identifies an instance of a business process definition between two trading partners, which enables the trading partners to relate two or more messages to the same process instance.

Global uniqueness is NOT REQUIRED. Uniqueness requirements will be AUBTP.

2.5.6 messageId

messageId identifies a message. It must be globally unique from a business perspective. In other words, every message queued for delivery from a business perspective must have a unique identifier. Transport services may need to send a message more than one time to ensure delivery. With each attempt to send the same message, the messageId MUST remain the same.

2.6 Usage Definition of "outboundData" Elements (i.e., Response)

2.6.1 processStep

See discussion of processStep in the inboundData Elements section above.

2.6.2 messageId

See discussion of processStep in the inboundData Elements section above.

2.7 Partner Identification Issues

For any given message there are potentially at least three ways a partner may be identified:

  • WS-Security Username/Password
  • partnerId/partnerType element values
  • information expressed in the xmlPayload element content

When information may be expressed in two or more places in a message, the possibility exists that the identifiers fail to resolve to the same expected partner. Testing for such issues is NOT REQUIRED (by this specification). Furthermore, if such issues are identified, this specification does not specify how they MUST or even SHOULD be addressed.

2.7.1 Service Provider Message Processing Issues

A service provider MUST return a SOAP fault response under the following conditions:

  • The client message does not conform to the schema specified in the WSDL
  • The client message does not contain an inboundData element
  • WS-Security is required and the client fails authentication
  • WS-Security is required and the client fails authorization

A service provider MAY return a SOAP fault response under the following conditions:

  • Missing business data
  • Invalid business data
  • WS-Security is used, the
  • Internal issues at the service provider
  • Other reasons request processing failed

It is RECOMMENDED that the SOAP fault responses contain an explanation of the fault. A service provider is NOT REQUIRED to log SOAP fault responses. In some cases this may mean that the client must maintain artifacts sufficient to investigate issues.

SOAP fault responses must not contain a messageId, a processStep, or an outboundData element.

3.0 Sample Request XML – Generic Request XML Message

A more fitting section title is suggested. Is this Errata and context?

Work on the GenericDocumentRequest will continue, including refinement of the schema and specification of how the parameters should be used, so that it can be used with future services. This work, including the full GenericDocumentRequest schema, will be included in future versions of this document.

Some specifications and notes so far on this Generic Request document: Are these specifications or are they business rules implied by the document?

  1. If parameters StartDate/EndDate and DocumentReference are not sent, then the consumer would receive all documents that are queued up for that specific consumer.
  2. If parameters StartDate/EndDate OR DocumentReference are sent, then the returned list is based on the parameters whether or not the documents have been sent.

Here are some of the questions regarding the use of the GenericDocumentRequest parameters which have been identified so far:

  • What combination of parameters means to send all documents (e.g. ShipNotices or Invoices) not previously sent?
  • When StartDate/EndDate are set, does it mean to send all documents between those dates which were not previously sent, or does it mean to resend already-sent documents only, or does it mean send all whether previously sent or not?
  • If MaximumDocuments is specified, what is the ordering criteria if any (oldest first, newest first, something else)?
  • If DocumentReference is set, does the client wants that document whether it has previously received it or not? Note the particular data element in the desired document which the DocumentReference value is supposed to match must be specified for each service, e.g. for ShipNotice it should match CIDX element xxx/yyy/zzz/etc (full XPath to CIDX element). Also, is it supposed to be an exact match, or a “starts with” match?
  • When documents are sent due to StateDate/EndDate or DocumentReference being set, does this mean they are then considered already sent for purposes of the client later requesting all unsent documents?

Another area to be reviewed is the desired response when GenericDocumentRequest is used. Assuming multiple documents can be returned, should they be returned in multiple xmlPayload elements (one document per xmlPayload element), or should we define collection elements analogous to the CIDX ShipNoticeList and InvoiceList and send that in a single xmlPayload element, or can this vary depending on the specific service?

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soapenv:Header>
    <wsse:Security
      xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
      xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
      <wsse:UsernameToken>
        <!--Scenario Name plus 3 digit ID-->
        <wsse:Username>user id</wsse:Username>
        <!--Password for Test Harness-->
        <wsse:Password
          Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"><![CDATA[password]]></wsse:Password>
        </wsse:UsernameToken>
        <wsse:Nonce>null</wsse:Nonce>
        <wsu:Created>null</wsu:Created>
    </wsse:Security>
  </soapenv:Header>
  <soapenv:Body xmlns:ns1="urn:aggateway:names:ws:docexchange">
    <ns1:inboundData>
      <businessProcess>SCShipNotice</businessProcess>
      <processStep>ShipNoticeListRequest</processStep>
      <partner>0576403930000</partner>
      <messageId>5678</messageId>
      <xmlPayload>
        <GenericDocumentRequest Version="5.1">
          <Header>
            <ThisDocumentIdentifier>
              <DocumentIdentifier>207978</DocumentIdentifier>
            </ThisDocumentIdentifier>
            <ThisDocumentDateTime>
              <DateTime DateTimeQualifier="On">20050523T160007Z</DateTime>
            </ThisDocumentDateTime>
            <From>
              <PartnerInformation>
                <PartnerName>GROWMARK, Inc.</PartnerName>
                <PartnerIdentifier Agency="D-U-N-S"
                  >0576403930000</PartnerIdentifier>
                <AddressInformation>
                  <AddressLine>1701 Towanda Ave</AddressLine>
                  <CityName>Bloomington</CityName>
                  <StateOrProvince>IL</StateOrProvince>
                  <PostalCode>61761</PostalCode>
                  <PostalCountry>US</PostalCountry>
                </AddressInformation>
              </PartnerInformation>
            </From>
            <To>
              <PartnerInformation>
                <PartnerName>Big Guy</PartnerName>
                <PartnerIdentifier Agency="D-U-N-S"
                  >1234567890000</PartnerIdentifier>
                </PartnerInformation>
            </To>
          </Header>
          <GenericDocumentRequestBody>
            <DocumentType>ShipNoticeList</DocumentType>
            <StartDate>20050523T160007Z</StartDate>
            <EndDate>20050523T160007Z</EndDate>
            <MaximumDocuments>20</MaximumDocuments>
            <DocumentReference>12345</DocumentReference>
          </GenericDocumentRequestBody>
        </GenericDocumentRequest>
      </xmlPayload>
    </ns1:inboundData>
  </soapenv:Body>
</soapenv:Envelope>

3.1 Parameters in the Generic Document Request

Parameter NameElement DescriptionRequired
DocumentTypeElement should contain the value of the root tag/document being requested.Yes
DateRange – StartDate, EndDateDateRange – StartDate, EndDateNo
MaximumDocumentsMaximum number of documents the consumer wants to receive back.Yes
DocumentReferenceSpecific document ID on transaction being requested. If sent, then takes precedence over StartDate and EndDate.No

 

3.2 Sample web service Response XML

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:ns0="urn:aggateway:names:ws:docexchange">
  <env:Body>
    <ns0:outboundData>
      <processStep>ShipNoticeList</processStep>
      <messageId>456</messageId>
      <xmlPayload>
        <ns1:ShipNoticeList xmlns="urn:ecms:schema:shipnotice:response:1:0"
          xmlns:cidx="urn:cidx:names:specification:ces:schema:all:4:0"
          xmlns:ns1="urn:ecms:schema:shipnotice:response:1:0"
          xmlns:ecms="urn:ecms:schema:shipnotice:response:1:0" Version="1.0">
          <cidx:Header xmlns:cidx="urn:cidx:names:specification:ces:schema:all:4:0">
            <cidx:ThisDocumentIdentifier>
              <cidx:DocumentIdentifier>489</cidx:DocumentIdentifier>
            </cidx:ThisDocumentIdentifier>
            <cidx:ThisDocumentDateTime>
              <cidx:DateTime DateTimeQualifier="On"
                >2008-05-19T17:17:56Z</cidx:DateTime>
            </cidx:ThisDocumentDateTime>
            <cidx:From>
              <cidx:PartnerInformation>
                <cidx:PartnerName>GROWMARK INC</cidx:PartnerName>
                <cidx:PartnerIdentifier Agency="AGIIS-EBID"
                  >0576403930000</cidx:PartnerIdentifier>
              </cidx:PartnerInformation>
            </cidx:From>
            <cidx:To>
              <cidx:PartnerInformation>
                <cidx:PartnerName>LINCOLN LAND FS INC</cidx:PartnerName>
                <cidx:PartnerIdentifier Agency="AGIIS-EBID"
                  >1563760970000</cidx:PartnerIdentifier>
              </cidx:PartnerInformation>
            </cidx:To>
          </cidx:Header>
          <ns1:ShipNoticeListBody>
            <ns1:ShipNoticeListProperties/>
            <ns1:ShipNoticeListDetails>
              <ns2:ShipNoticeBody
                xmlns:ns2="urn:cidx:names:specification:ces:schema:all:4:0">
                <ns2:ShipNoticeProperties>
                  <ns2:ShipmentIdentification>
                    <ns2:DocumentReference>
                      <ns2:DocumentIdentifier>8731832</ns2:DocumentIdentifier>
                    </ns2:DocumentReference>
                  </ns2:ShipmentIdentification>
                  <ns2:ShipDate>
                    <ns2:DateTime DateTimeQualifier="On"
                      >2008-05-16T05:00:00Z</ns2:DateTime>
                  </ns2:ShipDate>
                  <ns2:PurchaseOrderInformation>
                    <ns2:DocumentReference>
                      <ns2:DocumentIdentifier>8731832</ns2:DocumentIdentifier>
                    </ns2:DocumentReference>
                  </ns2:PurchaseOrderInformation>
                  <ns2:TransportMethodCode Domain="UN-Rec-19"
                    >6</ns2:TransportMethodCode>
                  <ns2:ReferenceInformation ReferenceType="DeliveryNoteNumber">
                    <ns2:DocumentReference>
                      <ns2:DocumentIdentifier>8731832</ns2:DocumentIdentifier>
                    </ns2:DocumentReference>
                  </ns2:ReferenceInformation>
                  <ns2:ShipNoticeDate>
                    <ns2:DateTime DateTimeQualifier="On"
                      >2008-05-19T17:17:56Z</ns2:DateTime>
                  </ns2:ShipNoticeDate>
                </ns2:ShipNoticeProperties>
                <ns2:ShipNoticePartners>
                  <ns2:Buyer>
                    <ns2:PartnerInformation>
                      <ns2:PartnerName>LINCOLN LAND FS INC</ns2:PartnerName>
                        <ns2:PartnerIdentifier Agency="AGIIS-EBID"
                          >1563760970000</ns2:PartnerIdentifier>
                    </ns2:PartnerInformation>
                  </ns2:Buyer>
                  <ns2:Seller>
                    <ns2:PartnerInformation>
                      <ns2:PartnerName>GROWMARK INC</ns2:PartnerName>
                      <ns2:PartnerIdentifier Agency="AGIIS-EBID"
                        >0576403930000</ns2:PartnerIdentifier>
                    </ns2:PartnerInformation>
                  </ns2:Seller>
                </ns2:ShipNoticePartners>
                <ns2:ShipNoticeDetails>
                  <ns2:ShipNoticeProductLineItem>
                    <ns2:LineNumber>1</ns2:LineNumber>
                    <ns2:ProductIdentification>
                      <ns2:ProductIdentifier Agency="AGIIS-ProductID"
                        >629245288686</ns2:ProductIdentifier>
                      <ns2:ProductName>OPTIMIZE SOYBEAN GROWTH PROMOTER 200
                        UNIT/10,000#</ns2:ProductName>
                    </ns2:ProductIdentification>
                    <ns2:ShippedQuantity>
                      <ns2:Measurement>
                        <ns2:MeasurementValue>2</ns2:MeasurementValue>
                        <ns2:UnitOfMeasureCode Domain="UN-Rec-20"
                         >EA</ns2:UnitOfMeasureCode>
                      </ns2:Measurement>
                    </ns2:ShippedQuantity>
                  </ns2:ShipNoticeProductLineItem>
                </ns2:ShipNoticeDetails>
              </ns2:ShipNoticeBody>
            </ns1:ShipNoticeListDetails>
          </ns1:ShipNoticeListBody>
        </ns1:ShipNoticeList>
      </xmlPayload>
    </ns0:outboundData>
  </env:Body>
</env:Envelope>
  • No labels

2 Comments

  1. Jim, in section 2, where can RFC 2119 be found?  Is this in OASIS, or somewhere else?


     

    1. There's a link to the spec in the preceding sentence.