Home > EAI, Oracle, Siebel > Siebel Web Service Call with SOAP

Siebel Web Service Call with SOAP

If you’re currently working with Siebel you might be familiar with their SOAP interface. When the software was originally developed, this was in accordance with best practices. However, today REST has become the dominant standard for connectivity on the web, so if you’re consuming Siebel with Ruby, PHP, Python, .NET, you’re probably looking for a REST API. Siebel does support REST, but you must buy Fusion Middleware, a costly addon to your existing platform.

This tutorial will give you basic steps for consuming the SOAP API directly from Node.js. You’ll see that the SOAP connection is fairly straightforward with the help of some libraries. Our demonstration will use the order creation service – which is what you’d use if you were building an ecommerce site that needed to submit orders to Siebel.

By consuming SOAP directly, we can avoid the extra costs of the REST translation, with very little down side.

Siebel API Overview

Siebel’s API is organized by:

Service – This is a high level grouping that covers a whole area of the API. For instance, we’ll be working with the Order Management service.
Port – This is a specific resource managed by the service. For instance, within the Order Management service you will find two ports – Order and OrderItem.
Method – This is the actual process that you will interact with. Among others each PORT will have the familiar CRUD operations.

Termonology: When I say “service” I often mean a single function, which in Siebel/SOAP terminology is a “method”. Sorry in advance for any confusion.

You can find a reference for the Siebel Order Management API here. Scroll to the bottom section for a list of the methods.

What You’ll Need

Siebel instance v7.8 or later

I’m going to assume that if you’re reading this article you’re probably already using Siebel and have an instance available.

Node.js v0.10.0 or later

You’ll need this to run our sample code. Node includes a package manager (npm) which will bring in all the other dependencies we need.

A terminal

If you’re in Windows I’d recommend git-bash.

A text editor

Whatever you’re comfortable with here. My code is written in CoffeeScript with 2 spaces for indentation, so if you’re going to edit that, make sure you’re not mixing tabs in or you’ll get strange syntax errors.

Overview of the Node-Siebel Project

The primary responsibilities we’ve taken on with node-siebel are:

  1. Generate services that can be called programmatically. We make some assumptions about the data formats in an attempt to make your life easier, so this probably won’t work for a non-Siebel API.
  2. Create a REST router for the services and hand it back to you. This is something you can plug in as express/connect/http middleware in node, and start serving your REST endpoints in just a few lines of code.

Let’s walk through the included tests, which should give you a sense of how to utilize this functionality in your own app. Go ahead and open the tests, which you’ll find here.

The first test, “should generate services” shows the services that will be generated from the sample WSDL, which is for the Order service. Each “service” in our world corresponds to a “method” in the SOAP world.

The next test “should create an order” demonstrates calling a service. If you look at the sample data being passed, you’ll notice that it differs from the message schema in the WSDL. Namely, the header elements are included for you, and you are just responsible for specifying the fields in a single document, represented as an object. This is in attempt to be more consistent with what I would expect from a REST interface. You’ll still need to provide the list/header elements for any sub-documents (e.g. OrderItems). Refer to the WSDL for the exact schema, and print the last request if you’re unsure what’s being sent.

NOTE: The Id and OrderNumber fields have a unique constraint, so you’ll need to change the values in order to run this multiple times.

The next test “should list orders” doesn’t really add much that’s new, but it’s not stateful, so you can safely run it many times.

The last test, “should generate REST API” is an integration test. It should be pretty close to the code you’d need to integrate with your own application.

You’ll notice that in addition to returning a set of services, the serviceGenerator also gives you a router. This can be plugged into connect or express, just as any other middleware would be. It has REST routes preconfigured that will forward your requests to the node-soap client, which communicates with the SOAP interface.

The code used to configure the connect middleware and start a server is standard boilerplate, and well documented in the Connect project.

Using Your Own Siebel Services

Assuming your API follows the same conventions as the Siebel standard methods, things will be easy. (Nothing is easy though, so brace yourself.)

Install Node-Siebel

npm install --save node-siebel

Obtain a WSDL

To communicate with other standard Services, or a custom one that you’ve created, you’ll need a WSDL file. This is an XML file that contains a description of where the service is and what it’s capabilities and requirements are.

Let’s go grab one from Administration – Web Services.

  1. Make sure the Siebel instance is running.
  2. Navigate to the Siebel Client in Internet Explorer.
  3. Log in as sadmin.
  4. Go to the Administrative – Web Services tab.
  5. Find the service you want to connect to and select it.
  6. Click the Generate WSDL button and complete the wizard.
  7. Transfer the WSDL file to the machine and project directory where you’ll be coding.

For reference, the Administrative – Web Services screen should look like this:

web services interface

Towards the end of your WSDL file you will find one or more <soap:address> fields. You’ll need to modify the hostnames to match the actual location of your dev server. I found in my tests that I needed to change SecureWebService to WebService, and add &WSSOAP=1 at the end. Here’s some info about the setting.

Connecting

Look at our test helper for an example of how to initialize the Node-Soap library… or follow the node-soap docs.

Option A: Programmatic Access

You can probably just use the node-soap client directly if you just need programmatic access. But if you prefer to not have to include the headers in the document, go ahead and follow the “should create an order” test example.

Option B: REST Access

Follow the example on in the main README. This should have everything you need.

Install

npm install node-siebel

Run Tests

npm install -g mocha
mocha

Tutorial

For more details and background, please see the tutorial.

Create A REST Server

With some minor changes, this should allow you to start a REST server that forwards requests to a node-soap client.

This is from example.js.

// get HTTP modules
var connect = require('connect'),
    http = require('http'),
    request = require('request'),
    server = connect();

// create a node-soap client
var soap = require('soap'),
    join = require('path').join,
    wsdlPath = join(__dirname, "../data/OrderWebService.WSDL"),
    username = 'SADMIN',
    password = 'SADMIN',
    sessionType = 'None';

soap.createClient(wsdlPath, function(err, client) {
    if (err) {
      throw err;
    };

    client.addSoapHeader("<UsernameToken xmlns='http://siebel.com/webservices'>" + username + "</UsernameToken>");
    client.addSoapHeader("<PasswordText xmlns='http://siebel.com/webservices'>" + password + "</PasswordText>");
    client.addSoapHeader("<SessionType xmlns='http://siebel.com/webservices'>" + sessionType + "</SessionType>");

    // create a REST router to forward to the node-soap client
    var serviceGenerator = require('node-siebel'),
        router = serviceGenerator(client).router;

    // connect the router and start the server
    server.use(connect.bodyParser());
    server.use(router);
    http.createServer(server).listen(4000);
});

REST endpoints will be generated based on the WSDL you provide. An example Siebel Order Management WSDL is provided which will generate the following endpoints:

POST   /order/:Id  =>  Order/SynchronizeOrder
DELETE /order/:Id  =>  Order/DeleteOrder
GET    /order/:Id  =>  Order/GetOrderById
PUT    /order/:Id  =>  Order/UpdateOrder
GET    /order      =>  Order/GetOrder
POST   /order      =>  Order/InsertOrder

anything else

POST /order/<action>  =>  Order/<action>

Advertisements
Categories: EAI, Oracle, Siebel Tags: , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: