In this exercise we will be connecting to a free online web service that performs weight conversions from any measurement of weight to any other measurement of weight. No inbound or outbound templates are necessary for this sample, we will be passing CONSTANT values to the web service, and the return values we receive will be sent directly to the local file system.
You can use either a Get Data workflow item or a Send Data workflow
item to connect and execute a web service. The examples below
demonstrate both ways.
The Web Service is located at: http://www.webservicex.net/ConvertWeight.asmx?op=ConvertWeight.
The SOAP Request and Response are provided below as a reference for the remainder of this tutorial.
The following is a sample SOAP request and response. The placeholders shown need to be replaced with actual values.
POST /ConvertWeight.asmx HTTP/1.1
Host: www.webservicex.net
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://www.webserviceX.NET/ConvertWeight"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope"http://www.w3.org/2001/XMLSchema-instance""http://www.w3.org/2001/XMLSchema""http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ConvertWeight"http://www.webserviceX.NET/">
<Weight>double</Weight>
<FromUnit>Grains or Scruples or Carats or
Grams or Pennyweight or DramAvoir or DramApoth
or OuncesAvoir or OuncesTroyApoth or Poundals
or PoundsTroy or PoundsAvoir or Kilograms or Stones
or QuarterUS or Slugs or weight100UScwt or ShortTons
or MetricTonsTonne or LongTons</FromUnit>
<ToUnit>Grains or Scruples or Carats or Grams
or Pennyweight or DramAvoir or DramApoth or OuncesAvoir
or OuncesTroyApoth or Poundals or PoundsTroy or
PoundsAvoir or Kilograms or Stones or QuarterUS
or Slugs or weight100UScwt or ShortTons or MetricTonsTonne
or LongTons</ToUnit>
</ConvertWeight>
</soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope"http://www.w3.org/2001/XMLSchema-instance""http://www.w3.org/2001/XMLSchema""http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ConvertWeightResponse"http://www.webserviceX.NET/">
<ConvertWeightResult>double</ConvertWeightResult>
</ConvertWeightResponse>
</soap:Body>
</soap:Envelope>
Retrieving data from an external web service via a Get Data workflow item is the most basic way to connect and receive a SOAP response. You have fewer options to configure than using a Send Data workflow item; however it is important to note that both ways can accomplish the same task.
Right click in the Workflow Group Navigator on the Workflow Group you want to use for this sample. From the context menu, select "New Workflow Wizard", select "New workflow", click next. Name the workflow "GetFromExternalWebService" and click finish. BridgeGate™ will force the name to lower case.
Figure: Creating a new Workflow
The new workflow will be created and open. In the Workflow Item Navigator, right click and select "New Get Data".
Name the Get Data "Get Data From External Web Service". Choose the Connection Type "Web Service". Below are screen shots of the Web Service connection information, and the various tabs you will need to fill out.
Figure: Operations tab of the Web Service Connection Type for the Get Data workflow item
Operations Tab | Value |
---|---|
Use WSDL | Check this box to use a WSDL for our tutorial |
WSDL (File or URL) | Enter test data to test your alpha mask. |
Test Result | http://www.webservicex.net/ConvertWeight.asmx?WSDL or download to local file system and select from '…' |
Binding |
Automatically loads, select 'ConvertWeightsSoap' |
Operation |
Automatically loads, select 'ConvertWeight' |
Service-Port |
Automatically loads, select 'ConvertWeightsSoap' |
Service Endpoint URL |
Automatically populates with 'http://www.webservicex.net/ConvertWeight.asmx' |
User Name |
Not needed, used for secure web service (HTTP BASIC only) |
Password |
Not needed, used for secure web service (HTTP BASIC only) |
Use SOAP Response as Result |
This checkbox, when selected, wraps the values of the result in the XML returned from the web service. See the test results below. |
Figure: In Values tab of the Web Service Connection Type for the Get Data workflow item
The In Values screen will automatically populate with the required In Values from the WSDL you specified on the Operations tab. If you are not using a WSDL on the Operations tab, you are able to right click in the In Values and create new In Values.
In Values Tab | Value |
---|---|
Weight |
Choose Field Type 'CONSTANT' Enter Constant Value '40' |
FromUnit |
Choose Field Type 'CONSTANT' Select Constant Value 'Grams' |
ToUnit |
Choose Field Type 'CONSTANT' Select Constant Value 'OuncesTroyApoth' |
Figure: In Values tab of the Web Service Connection Type for the Get Data workflow item
The Out Values screen will automatically populate with the required Out Values from the WSDL you specified on the Operations tab. If you are not using a WSDL on the Operations tab, you are able to right click in the Out Values and create new Out Values.
In Values Tab | Value |
---|---|
ConvertWeightResults |
Do nothing. Use As Result is default. You can optionally add the result to the WF Session, which allows you to use it in other workflow items. Some examples are: Item List workflow item to compare the result and use alternate workflow flow Variable for math or concatenation or other formulas In a Send Data or Get Data connection information |
In the Workflow Item Navigator, right click and select "New Send Data".
Name the Send Data "Send Data to local file system". Choose the Connection Type "FILE". Below is a screen shot of the FILE connection information, and the various text boxes/drop downs you will need to fill out.
Figure: Send Data workflow item
Send Data widget | Value |
---|---|
Data Source Type |
FORWARD ONLY DATA |
Source Workflow Item |
Get Data From External Web Service; otherwise the name of the Get Data if you named it different |
Encoding |
UTF-8 is recommended when sending results from a web service, or any XML data in general. |
Connection Type |
FILE |
File Directory |
C:\temp or any other location you prefer |
File Name |
ounces_from_grams.txt or any other name you prefer |
On the operations tab, we opted to use a WSDL to automatically discover the connection information and the in/out values. We could also choose not to use a WSDL, but then you must obtain the connection information and the in/out values from the company or department you will be connecting to.
Ensure that the workflow you just created is saved. Go to the Test Workflow Screen, and select the workflow you just created in the proper workflow group. You can also select the samples7 workflow group, and GetFromExternalWebService workflow. Click the start button in the navigation menu and wait for the workflow to complete. The screen shot below shows the Result of the Send Data, which is a SOAP response with the converted grams into ounces.
Retrieving data from an external web service via a Send Data workflow item allows more options in how you connect and receive the SOAP response than using a Get Data, however it is important to note that both ways can accomplish the same task. Because we can use either a Get or Send Data workflow item, the web service screen is the same for both. The information you enter will be the same as in the first section for Get Data. For the remainder of this section we will only cover the rest of the options available on a Send Data that you do not have on a Get Data.
You can use web services like other synchronous types, allowing you to use a Get Data workflow item to receive the response. This is a checkbox on the Operations tab.
If your data contains the XML wrapper that the data will use inside the SOAP request, you can check this box. By default this option is not checked and BridgeGate™ automatically generates the XML wrapper for you. This is also a checkbox on the Operations tab.
Unlike using a Get Data, if you wish to use values from translated data in the In Values, a Send Data is the better choice. Also, if your data, including the XML wrapper, is in a file you wish to forward directly to the web service, a Send Data is also the better choice.
This section walks you through creating a web service exposed by BridgeGate™ for other systems to connect to. When another system connects to BridgeGate™ via this exposed web service, you can use BridgeGate™ handle that data send and return the response.
Start by creating a workflow in the same way you have in the previous sections of this tutorial. Name the Get Data "Get Data From BridgeGate Web Service". Choose the Connection Type "BridgeGate Web Service". Also check the box to "Enable workflow to be executed as a Service".
Below are screen shots of the Web Service connection information, and the various tabs you will need to fill out.
Operation Tab | Value |
---|---|
Use WSDL |
Leave this checkbox unchecked if you do not have a WSDL already created for the web service you want to create with BridgeGate™ |
Service Endpoint URL |
This text box is grayed out. This URL is automatically created for you. It uses the BridgeGate Server URL you are currently logged into, and has the URI /services/account/serviceName appended to it. The URL is used by other systems to connect to this web service. |
Service Name |
Create a unique name for the service you want to create. It is appended at the end of the Service Endpoint URL, which other systems use to connect to this web service. |
Target Namespace |
This namespace is commonly created as an URL for your company or organization. It is not to be confused with the Service Endpoint URL. |
Response Element |
Create the name for the XML wrapper to use to return the result |
Request Element |
Create the name for XML wrapper to use that contains the request |
SOAP Action |
Not required for BridgeGate web services |
Define the parameters you will require for your web service. Right click on the list to create a new in value. All in values are treated as x:string. Enter a name for the in value, it will be the name used in the XML the SOAP request contains.
Define the return values to send back in the SOAP response. These values can be from the results of translated data, or can be from CONSTANT values.
Once the workflow is on the BridgeGate Server, the Service becomes active. You can test for the web service by opening a web browser and entering the Service Endpoint URL generated on the Operations Tab above. Be sure to test the URL generated by your workflow. http://qa.bridgegatedev.com/services/samples/inventoryService?WSDL