Web Service Example - Creating a Web Service Provider Workflow(4.3)

Web Service Example - Creating a Web Service Provider Workflow(4.3)

A Web Service Provider workflow consists of a Web Service Provider agent (collection), and an Analysis agent. The Web Service Provider agent routes UDRs 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 view, click the  Browse... button.

    The Configuration Selection dialog opens.
     

  2. Select Example and click OK.

    In the Web Service profile text box, example.charge appears.
     

  3. Set the  Workflow Response Timeout to 3000 ms.
     

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

  5. In the Analysis agent 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.

     

  6. Click the Compilation Test button in the Analysis agent.

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

  7. Click Set To Input in the Analysis agent. Click OK.