Salesforce

How Do I Implement a Web Services Trigger? (Magic xpi 3.x)

« Go Back

Information

 
Created ByKnowledge Migration User
Approval Process StatusPublished
Objective
Description

How Do I Implement a Web Services Trigger? (Magic xpi 3.x)

This How To topic will guide you through building a Magic xpi project that will be a Web service provider. The service will receive two numeric arguments from a Web services consumer (client). Magic xpi will receive the request, calculate the sum of the two numbers, and return it to the consumer.

  1. Open the Resource Repository and define a new Web Service Server resource, with Systinet connection details. The default connection values are:

    • Server URL: http://localhost:6060

    • User name: admin

    • Password: changeit

  2. Open the Service Repository and define a new Web Services service, named SumService.

  3. In the Service Setting dialog box, select the previously created Web Service Server resource as the Web Service Provider. Enter a Web Service Name and use the default values for the remainder of the parameters, and click the Operations button, as shown below.

  1. In the Operations dialog box, you should now define the Add operation and its arguments. Click the New button to create a new operation, and name it Add.

  2. In the Arguments section of the Operations dialog box, change the return value name to Sum, and change the type to Numeric.

  3. Add two more arguments and name them num1 and num2. Set their Direction to In, and their Data Type to Numeric, as shown below.

Click OK to return to the Service Setting dialog box.

  1. In the Service Setting dialog box, click the Management button to open the deployment Management dialog box.

  2. In the deployment Management dialog box, you can generate the Magic xpi service and the Systinet .jar file. When you check the Deploy Web Service box, the service is deployed to the Systinet server, enabling it to function.

  3. Click the Generate button to deploy the new service.

You should see the following message if the service was successfully deployed, or an error message with details if something went wrong.

If you get an error message, or a Not Authorized 404 message, you should check that the connection details in the Web Service Server resource are correct. You should also try to log in to the Systinet console with the same user name and password.

If the generation and deployment of the service was successful, you can use the new service in a flow. To do this, follow these steps:

  1. From the Insert menu, click Flow. Name your new flow AddFlow.

  2. From the flow's context menu, click Variables (or use Ctrl+L) to open the Variables for Flow dialog box. Create the following flow variables:

Variable Name

Type

Description

F.num1

Numeric

The first number.

F.num2

Numeric

The second number.

F.num

Numeric

The sum of the two numbers.

  1. Drag a Web Services service to the flow trigger area. The Component Properties dialog box opens.

  2. Click the Settings tab, and select SumService from the Service Name drop-down list. Click Configuration, as seen below.

  1. In the Component Configuration: Web Service dialog box, select Add from the Operation Name drop-down list.

  2. In the Return expression, use the F.sum variable.

  3. For parameters Num1 and Num2, use the F.num1 and F.num2 variables respectively, as seen below.

  1. Click OK to exit the configuration of the component.

  2. Next, drag a Flow Data service to the flow area, and update the f.sum expression with the sum of F.num1+F.num2, as seen below.

The resulting flow should look like this:

  1. From the File menu, select Build Executable File to generate the flow for deployment.

Testing the Service

To test your new Web service, follow these steps:

  1. Make sure that the Java runtime engine is installed by checking the %Java_Home% system variable.

  1. Go to Start->My computer, and from the right-click menu, select Properties.

  2. From the Advanced tab, select Environment variables. You should see JAVA_HOME listed.



    You can also issue the “%JAVA_HOME%\bin\java” -version command at the command prompt.



    If either of these does not work, you may have an installation issue. Re-installing Magic xpi may solve the problem.

  1. Start the project in the Server, either from the project start link or from the Magic xpi Monitor, and verify that it started successfully.


  2. Open an Internet browser (Internet Explorer or Mozilla Firefox) and call the Systinet console URL (http://localhost:6060/admin/console). You should see the following screen.

Log in using your Systinet user name and password.

  1. Navigate to your service in the Web Services Tree, and click the Invocation Console button, as shown below.

  1. Select the operation that you want to test, fill in the test data, and click the Perform call button, as shown below.

  1. A successful call should look like the image below.

Note:

You can also test the service from any external tool (such as XML Spy), from a Web service studio, or from code.

Reference
Attachment 
Attachment