Custom DFS service development.

Source: Internet
Author: User
Document directory
  • Related Posts
  • Related Posts

First, send a video.

Https://community.emc.com/servlet/JiveServlet/download/1723-1-1461/service_catalog_demo.exe

 

Article: http://www.dfsnotes.com/2007/11/14/custom-dfs-service-development-service-creation-part-1/

Some persons from EMC Documentum Forums stated that AcmeCustomService which comes with dfs sdk seems to be too complex for beginners, and "HelloWorld" service wocould be more understandable. I will try to show you how to create your first own simple HelloWorld like DFS service.

This tutorial will contain of 3 parts:

  • Service creation
  • Java client creation
  • . NET remote client

Before we'll start, we shocould setup our build environment.

Note: You shoshould have ant installed in order to run tutorial scripts.

1. Download attached helloworldservice.zip and extract it into emc-dfs-sdk-6.0 \ samples folder. It contains project template similar to AcmeCustomService. Lets assume "HelloWorldService" folder as root.

2. Open etc \ dfc. properties and set host, repository name, username and password for your docbase.

3. Open build. properties and set preferred context root and module names, or leave them as they're now.

Here is service code:

Package com. service. example;

Import com.emc.doc umentum. fs. rt. annotations. DfsPojoService;

@ DfsPojoService (targetNamespace = http://example.service.com, requiresAuthentication = true)
Public class HelloWorldService
{
Public String sayHello (String name)
{
Return "Hello" + name;
}
}

@ DfsPojoServiceAnnotation specifies service's namespace, and states if service requires docbase authentication (true by default)

Place this source with appropriate package into src \ service folder.

Go to root folder (HelloWorldService) and run from command line the following command:

Ant artifacts package

This command converts annotated classes to DFS services and package them into ear file.

At this step, you shoshould have example. ear deployment file in HelloWorldService \ build folder. This ear file contains our service which can be deployed into Weblogic application server.

Copy this file into weblogic's autodeploy directory. You can also set weblogic deployment dir at autodeploy. properties file and run"Ant deploy"Command.

With default values at build. properties, your service shocould be available by the path: http: // host: port/services/example/HelloWorldService

That's all for now. In the next part of tutorial I will explain how to create client and call this service remotely.

 

Today we'll talk about remote client creation which invokes our HelloWorldService from part 1.

Little more info about this sample:

 

  • Before running remote client, HelloWorldService shoshould be built and packaged.
  • Since HelloWorldService requires authentication, the service context shocould be provided with at least one identity. A service context is expected to contain only one identity per repository name.
  • We invoke HelloWorldService remotely, and therefore we shoshould provide client with connection details. This can be done through two ways:
    1. Using dfs-client.xml config file: You shoshould have it under "resources/config" folder.
    2. Using overrided methods of ContextFactory and ServiceFactory factories, it allows to specify explicit location of service:
      IServiceContext registeredContext = ContextFactory. getInstance (). register (context, moduleName, contextRoot );
      ServiceFactory. getInstance (). getRemoteService (IHelloWorldService. class, registeredContext, moduleName, contextRoot );

Most common scheme of creating and invoking authorized service remotely consists:

  1. Create service context.
  2. Fill it with identities.
  3. Register context at Context Registry Service and get "clean" context.
  4. Get required service by implemented interface.
  5. Invoke service's method.

Below is full source code of remote client:

Package com. client. example;

Import com.emc.doc umentum. fs. datamodel. core. context. RepositoryIdentity;
Import com.emc.doc umentum. fs. rt. ServiceException;
Import com.emc.doc umentum. fs. rt. context. ContextFactory;
Import com.emc.doc umentum. fs. rt. context. IServiceContext;
Import com.emc.doc umentum. fs. rt. context. ServiceFactory;
Import com. service. example. client. IHelloWorldService;

Public class HelloWorldClient
{
Public static void main (String [] args)
{
String moduleName = "example ";
String contextRoot = "http: // localhost: 7001/services /";

ContextFactory contextFactory = ContextFactory. getInstance ();
IServiceContext context = contextFactory. newContext ();

RepositoryIdentity repoId = new RepositoryIdentity ();

RepoId. setRepositoryName ("repositoryName ");
RepoId. setUserName ("userName ");
RepoId. setPassword ("password ");
RepoId. setDomain ("");

Context. addIdentity (repoId );

Try
{
IServiceContext registeredContext = contextFactory. register (context, moduleName, contextRoot );
ServiceFactory serviceFactory = ServiceFactory. getInstance ();
IHelloWorldService service = serviceFactory. getRemoteService (IHelloWorldService. class, registeredContext, moduleName, contextRoot );
String response = service. sayHello ("John ");
System. out. println ("response =" + response );
}
Catch (ServiceException e)
{
E. printStackTrace ();
}
}
}

I 've updated helloworldservice.zip with remote client source code.

Next part of. NET remote client will be ready soon.

 

It's time to show you how to create. NET remote client for HelloWorldService.

In order to create. NET proxies for DFS service, developers shoshould have:

  • Service's wsdl url.
  • DFS service-model.xml file which describes service artifacts to be generated by subsequent processes.

 

The data above is required for DFS Proxy Generator tool which creates. net dfs proxy:

After creation of proxy, it can be used for service instantiation and invocation.

Below is source code which creates and invokes HelloWorldService. as I said in my previous post DFS 6.0 SP1 is coming, Java and. net dfs api's are very similar to each other, there is no conceptual differences between them.

Source code:

Using System;
Using Client. Service;
Using Emc. Documentum. FS. DataModel. Core. Context;
Using Emc. Documentum. FS. Runtime. Context;

Namespace Client
{
Class Program
{
Static void Main (string [] args)
{
String moduleName = "example ";
String contextRoot = "http: // localhost: 7001/services ";

ContextFactory contextFactory = ContextFactory. Instance;
IServiceContext context = contextFactory. NewContext ();
RepositoryIdentity repoId = new RepositoryIdentity ();
RepoId. RepositoryName = "yourreponame ";
RepoId. UserName = "yourusername ";
RepoId. Password = "yourpwd ";

Context. AddIdentity (repoId );

// Remote service invocation
IHelloWorldService mySvc;
Try
{
Context = contextFactory. Register (context, moduleName, contextRoot );
ServiceFactory serviceFactory = ServiceFactory. Instance;
MySvc = serviceFactory. GetRemoteService <IHelloWorldService> (context, moduleName, contextRoot );
String response = mySvc. SayHello ("John ");
Console. WriteLine ("response =" + response );
}
Catch (Exception e)
{
Console. Error. WriteLine (e. StackTrace );
}
}
}
}

This sample is also encoded in helloworldservice.zip.

P.S: Please note, that DFS SP1 is required in order to build this sample.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.