For Motorprise, we wrote and configured a simple SOAP client that sends a series of parameters as a SOAP message. The class that we created is located at atg.projects.b2bstore.soap.SimpleSOAPClient. This class allows the easy configuration of a SOAP client and its commonly changed values.

<ATG9dir>/MotorpriseJSP/j2ee-apps/motorprise/config/atg/projects/b2bstore/soap/SimpleSOAPClient.properties:

$class=atg.projects.b2bstore.soap.SimpleSOAPClient

SOAPServerURL=http\://hostname\:8080/Dynamo/solutions/B2BStore/soap
targetObjectURI=urn\:motorprise-display-xml
methodName=receiveDocument

In the properties file, the URL that the SOAP message is sent to is defined as http://hostname:8080/Dynamo/solutions/B2BStore/soap. The server listens for SOAP messages at this URL.

The targetObjectURI=urn\:motorprise-display-xml property indicates the service to which to route the message.

Finally, the methodName=receiveDocument property indicates which method on the configured service should be invoked. In this case, it is receiveDocument method, which simply displays an XML document to the Dynamo console.

The SendOrdersViaSOAP scenario has a custom action associated with it: atg.projects.b2bstore.soap.SendObjectAsXML. This is the part of the scenario that sends the order object as an XML document.

To implement this custom action in Motorprise, we modified the configuration file that controls the scenario server, /atg/scenario/scenarioManager.xml. We added the following lines to the file:

<!-- Action to send an object over a SOAP request -->
<!-- Used in Motorprise to demonstrate sending of -->
<!-- orders as an XML document.                  -->
<action>
  <action-name>
    Send Object As XML via SOAP
  </action-name>
  <action-class>
    atg.projects.b2bstore.soap.SendObjectAsXML
  </action-class>
  <resource-bundle>
    atg.projects.b2bstore.scenario.UserResources
  </resource-bundle>
  <display-name-resource>
    sendObjectAsXML.displayName
  </display-name-resource>
  <description-resource>
    sendObjectAsXML.description
  </description-resource>
  <action-execution-policy>
    collective
  </action-execution-policy>
  <action-error-response>
    delete
  </action-error-response>

  <!-- Parameter that indicates the object that will -->
  <!-- be marshalled to XML.                         -->
  <action-parameter>
    <action-parameter-name>
      marshalObject
    </action-parameter-name>
    <display-name-resource>
      sendObjectAsXML.marshalObject.displayName
    </display-name-resource>
    <action-parameter-class>
      java.lang.Object
    </action-parameter-class>
    <required>
      true
    </required>
    <description-resource>
      sendObjectAsXML.marshalObject.description
    </description-resource>
  </action-parameter>
  <!-- This is the key that will be passed to the -->
  <!-- to the ObjectMarshallerDispatcher service  -->
  <!-- The key is used to determine which         -->
  <!-- marshaller to use.                         -->
  <action-parameter>
    <action-parameter-name>
      marshalKey
    </action-parameter-name>
    <display-name-resource>
      sendObjectAsXML.marshalKey.displayName
    </display-name-resource>
    <action-parameter-class>
      java.lang.String
    </action-parameter-class>
    <required>
      false
    </required>
    <description-resource>
      sendObjectAsXML.marshalKey.description
    </description-resource>
  </action-parameter>
</action>

This code registers an action with the Scenario Server that will be displayed in the ACC as “Send Object As XML via SOAP.” This action takes two parameters, which are specified when creating the scenario in the ACC.

The first parameter, which is required, is marshalObject. This parameter is the object that is to be serialized to XML. Typically, this object comes from the source event.

The second parameter, which is optional, is marshalKey. This is a key object, provided by the user, that is passed to the ObjectMarshallerDispatcher to determine which ObjectMarshaller processor will perform the marshalling.

For more information, see the Using the Configuration Reporter section in the Monitoring Site Performance chapter of the ATG Installation and Configuration Guide.

In addition to configuring marshalObject and marshalKey, you can also modify the behavior of the SendObjectAsXML action. Most of its properties are configurable via the atg.projects.b2bstore.soap.SOAPResources file.

You can find the following resource strings in the SOAPResources file:

  • SimpleSOAPClient determines the Nucleus location of the SimpleSOAPClient to use when sending messages via SOAP. Its default is /atg/projects/b2bstore/soap/SimpleSOAPClient.

  • MarshalServicePath determines the Nucleus location of the ObjectMarshallerDispatcherService to use to marshal objects into XML documents. Its default is /atg/dynamo/service/xml/ObjectMarshallerDispatcher.

  • SOAPParameterName determines the name of the parameter that is embedded in the SOAP payload. Its default is xmlDocument.

For more information on creating custom actions for scenarios, see the Adding Custom Events and Actions to Scenarios section in the ATG Personalization Programming Guide.

 
loading table of contents...