Web Service Example - Creating a Web Service Provider Workflow

A Web Service Provider workflow consists of a Web Service Provider agent (collection), and an Analysis agent. The Web Service Provider agent routes UDRs, that are of the type WSCycle_charge, to the Analysis agent. The Analysis agent then routes the UDRs, carrying a response, back to the Web Service Provider agent.

The Web Service Provider workflow

Configuring the Agents

In the Workflow Editor, open the configuration views of both agents.
 

  1. In the Web Service Provider configuration dialog, click the  Browse... button.

    The Configuration Selection dialog opens.
     

  2. Select example and click OK.

    In the Web Service profile text box, example.charge will appear.
     

  3. Set the  Workflow Response Timeout to 3000 ms.
     

  4. In the  HTTP tab, assign the HTTP Address with a value by clicking on the  Extract Profile Settings button.
     

  5. Click  OK .
     

  6. In the Analysis configuration view, enter the following APL code:

    import ultra.ws.example.charge.cycles;
    import ultra.ws.example.charge.x1;
    
    consume {
       // Verifying that the UDR type is matches the
       // UDR definition generated by the WS profile.
    
       if (instanceOf(input, WSCycle_charge)) {
          // Cast the input type to the WSCycle_charge UDR.
    
          WSCycle_charge udr = (WSCycle_charge) input;
          string errorMessage = null;
          int faultReason = -1;
    
          // debug
          debug("The ServiceType is " + udr.param.serviceType);
          debug("The amount to charge is "
                + udr.param.chargingEvent.id);
          debug("The amount to charge is "
                + udr.param.chargingEvent.amount);
    
          // Perform some business logic ...
    
          // In case an error occurred when performing
          // the business logic, send back a fault
          if (errorMessage != null) {
             FaultDetail fault = udrCreate(FaultDetail);
             fault.message = errorMessage;
             fault.reason = faultReason;
             udr.fault_FaultDetail = fault;
             udr.errorMessage = errorMessage;
          }
          else {
             ChargeResult result = udrCreate(ChargeResult);
             result.success = true;
             result.message = "OK";
             udr.response = result;
          }
    
          // The UDR is routed back to the
          // Web Service Provider agent
          udrRoute(udr);
       }
    }

    The APL code first verifies that the UDRs that enter the workflow are of the WSCycle_charge type. If so, the UDRs are casted from the abstractWScycle type to the WSCycle_charge type.


  7. Click on the  Compilation Test  button.

    If the compilation fails check that the name of the folder in which you saved the WS profile is the same as in the path that the APL code specifies.
     

  8. Click on the  Set To Input .
     

  9. Click  OK .