CAA Web Services Home |
|
Consuming the ENOVWSConcEngCpp CAA Web ServiceUsing the ENOVWSConcEngCpp CAA Web Service for concurrent engineering management |
Use Case |
AbstractThis article discusses the CAAENOVWSConcEngCpp DotNet1_1Client use case. It describes how to use the C# client binding that can be generated using the wsdl.exe utility in order to consume the ENOVWSConcEngCpp CAA Web service. It provides a sample usage scenario that demonstrates how to handle lifecycle management. |
This use case demonstrates how to write a client application that consumes the ENOVWSConcEngCpp CAA Web service. It helps you to:
[Top]
CAAENOVWSConcEngCppUseCase is a use case of the CAAENOVWS.edu framework that illustrates the ENOVWSConcEngCpp CAA Web service capabilities.
[Top]
The sample usage scenario delivered with this use case contains the following steps:
The ENOVWSConcEngCpp CAA Web service is used in support of the primary objective of this use case, which is to manage concurrent engineering using the ENOVWSConcEngCpp CAA Web service.
[Top]
The CAAENOVWSDotNet1_1Client use case is made of several classes located in both CAAENOVWSDotNet1_1Client.m and CAAENOVWSDotNet1_1ClientBase.m modules of the CAAENOVWS.edu framework:
<Install>\CAAENOVWS.edu\CAAENOVWSDotNet1_1Client.m\src <Install>\CAAENOVWS.edu\CAAENOVWSDotNet1_1ClientBase.m\src |
<Install>
: the root directory where the CAA CD-ROM is installed.The CAAENOVWSDotNet1_1ClientBase.m module (library) contains the following resources:
<Source>\CAAENOVWSConcEngCppProxy.cs |
<Source>
: <Install>\CAAENOVWS.edu\CAAENOVWSDotNet1_1ClientBase.m\src
.The CAAENOVWSConcEngCppProxy.cs file contains the C# client binding generated using the wsdl.exe utility. A C# client binding consists of a proxy and several types definitions. The CAAENOVWSConcEngCppWrapper.cs file contains a class that describes how to configure the generated proxy and how to invoke its methods.
The CAAENOVWSDotNet1_1Client.m module (executable) contains the following resources:
<Source>\CAAENOVWSDotNet1_1Client.cs |
<Source>
: <Install>\CAAENOVWS.edu\CAAENOVWSDotNet1_1Client.m\src
.The CAAENOVWSDotNet1_1Client.cs file contains the main program. It parses the command line inputs and starts up the use case. The CAAENOVWSConcEngCppUseCase.cs file contains the sample use case scenario.
[Top]
To run the CAAENOVWSDotNet1_1Client use case, you will need to build both CAAENOVWSDotNet1_1ClientBase.m and CAAENOVWSDotNet1_1Client.m modules. The use case code can be built using either the CAA V5 buildtime environment, or Visual Studio .NET 2003 as explained in [1].
You can then execute the command described below:
|
<URI>
: is the root URI of the Web application where the
ENOVWSConcEngCpp CAA
Web service is deployed,<ENOVIA username>
: is a valid username declared in the ENOVIA P&O database,<Basic Authentication Username> and <Basic Authentication Password>
:
are a valid set of credentials for authentication on the remote Web server. Here follows a sample command, to be updated with your own environment configuration:
CAAENOVWSDotNet1_1Client -w http://stophe1dsy.dsy.ds:9080/B18 -e
auser -u wpsadmin -p wpsadmin -t ENOVWSConcEngCpp -n
TACR.ADMIN.DEFAULT |
The same executable is used to launch all of the available ENOVIA CAA Web services use cases. The
-t
option is used to choose the target use case to run.
When building the modules with the CAA V5 buildtime environment, the CAAENOVWSDotNet1_1Client executable can be launched from the following location:
<Install>\CAAENOVWS.edu\intel_a\code\clr |
<Install>
: the root directory where the CAA CD-ROM is installed.[Top]
The following section first explains how to generate the C# client binding for the ENOVWSConcEngCpp CAA Web service demonstrated. The remaining sections describe how to configure the generated proxy and how to consume the Web service:
[Top]
Please refer to [2] for details on how to generate the C# client binding using the wsdl.exe utility.
Here follows a sample command in order to generate the C# client binding for the ENOVWSConcEngCpp CAA Web service:
wsdl /namespace:com.dassault_systemes.caaenovws.caaenovwsdotnet1_1clientgen.ENOVWSConcEngcpp /username:wpsadmin
/password:wpsadmin /out:CAAENOVWSConcEngCppProxy.cs http://stophe1dsy.dsy.ds:9080/B18/wsdl?service=urn:com:dassault_systemes:ENOVWSConcEngImpl:ENOVWSConcEngImpl:ENOVWSConcEngCpp |
The server name, port, and context root URI information must be updated to match the server where the
ENOVWSConcEngCpp CAA Web service has been deployed. The /username
and /username
options are required to authenticate on the Web server hosting the Web service.
[Top]
In order to consume an implementation of the ENOVWSConcEngCpp CAA Web service deployed on a target Web server, you first need to instantiate the proxy generated using the wsdl.exe utility. This proxy must then be configured in order to manage authentication on the remote Web server, timeout, and session management. Maintaining the HTTP session state is mandatory when consuming ENOVIA LCA V5 CAA Web services.
The generated proxy class is used in order to marshall method calls and objects to SOAP requests, and to unmarshall SOAP responses to objects. The following code describes how to instantiate and configure it:
public class
CAAENOVWSConcEngCppWrapper { private const string SERVICE_ID = "urn:com:dassault_systemes:ENOVWSConcEngImpl:ENOVWSConcEngImpl:ENOVWSConcEngCpp"; private CAAENOVWSConcEngCppProxy proxy = null; public CAAENOVWSConcEngCppWrapper( CookieContainer container, string uri, string credUser, string credPwd, int timeOut) { proxy = new CAAENOVWSConcEngCppProxy(); // Compute the SOAP endpoint URI value that bounds to the deployed implementation of the // ENOVWSConcEngCpp CAA Web service proxy.Url = uri + "servicerouter?service=" + SERVICE_ID; // Required for HTTP session state management proxy.CookieContainer = container; // Required for the Basic Authentication mechanism ICredentials credentials = new NetworkCredential(credUser, credPwd); proxy.Credentials = credentials; // Increase the default client time-out proxy.Timeout = timeOut; } |
(1): in order to maintain the HTTP session state between successive calls performed
using either the same or multiple proxy instances, the CookieContainer
property must be
set on the proxy. This is mandatory in the context of ENOVIA LCA V5 CAA Web services,
(2): when security is enabled on the remote Web server, it is mandatory to set the
Credentials
property on the proxy. The values specified must match a valid set of credentials
for the Basic Authentication mechanism,
(3): the default timeout value can be increased in order to avoid potential issues
at runtime, such as losing the HTTP connection before receiving the SOAP responses. The value specified
in the code is in milliseconds.
[Top]
To create documents, you can use the following method available through the generated proxy interface:
ENOVIA LCA V5 Objects (Part and
Document) can be locked using the following method, which is
available through the generated IConcEngWS
proxy interface:
public Status Lock(Identifier[] iObjectIds) |
This method accepts the following parameters:
[in] iObjects |
Array of Identifiers |
[out] Status |
Return the status |
The following code demonstrates the use of the lock
method:
public class CAAENOVWSConcEngCppWrapper { public void Lock(String[] ids) { Console.Out.WriteLine(">>> Invoking 'lock' on ENOVWSConcEngCpp CAA Web service proxy"); if (ids == null) { throw new ApplicationException( "object UUID array is null"); } // Create input data Identifier[] idents = ToIdentifierArray(ids); // Invoke method on remote CAA Web service try { Status status = proxy.Lock(idents); Console.Out.WriteLine("Status: {0}", status.Status1); } catch (Exception e) { throw new Exception("Failed to lock objects", e); } } public Identifier ToIdentifier(string id) { if (id == null) { throw new ApplicationException("Illegal argument: identifier value is null"); } Identifier identifier = new Identifier(); identifier.Identifier1 = CAAENOVWSUtils.ConvertFromHexToBinary(id); return identifier; } public Identifier[] ToIdentifierArray(string[] ids) { if (ids == null) { throw new ApplicationException("Illegal argument: identifiers array is null"); } Identifier[] identifiers = new Identifier[ids.Length];
for (int i = 0; i < ids.Length; i++) {
identifiers[i] = ToIdentifier(ids[i]);
}
return identifiers;
} |
[Top]
ENOVIA LCA V5 Objects can be unlocked using the
following method, which is available through the generated ICntMgmtWS
proxy interface:
public Status Unlock(Identifier[] iObjectIds) |
Prerequisite: A ENOVIA LCA V5 Part Object should be existing.
This method accepts the following parameters:
[in] iObjects |
Array of Identifiers |
[out] Status |
Return the status |
The following code can demonstrates the use of the Unlock()
method:
public class CAAENOVWSConcEngCppWrapper { public void Unlock(String[] ids){ Console.Out.WriteLine(">>> Invoking 'unlock' on ENOVWSConcEngCpp CAA Web service proxy"); if (ids == null) { throw new ApplicationException( "object UUID array is null"); } // Create input data Identifier[] idents = ToIdentifierArray(ids); // Invoke method on remote CAA Web service try { Status status = proxy.Unlock(idents); Console.Out.WriteLine("Status: {0}", status.Status1); } catch (Exception e) { throw new Exception("Failed to unlock objects", e); } } |
[Top]
ENOVIA LCA V5 Document can be checked in using the following method, which is
available through the generated IConcEngWS
proxy interface:
ublic Status getLock(SessionToken iSessionToken, |
This method accepts the following parameters:
[in] iSessionToken |
The session token |
[in] iObjectIds |
The array of object identifiers |
[in/out] oLockInfos |
arrays of object lock information |
The following code demonstrates the use of the GetLock
method:
public class CAAENOVWSConcEngCppWrapper { public ObjectLockInfo[] GetLock(String[] ids) { Console.Out.WriteLine(">>> Invoking 'lock' on ENOVWSConcEngCpp CAA Web service proxy"); if (ids == null) { throw new ApplicationException( "object UUID array is null"); } // Create input data SessionToken token = new SessionToken(); //place holder not used Identifier[] idents = ToIdentifierArray(ids); // Invoke method on remote CAA Web service try { ObjectLockInfo [] lockHolder = null ; Status status = proxy.GetLock(token, idents, ref lockHolder); Console.Out.WriteLine("Status: {0}", status.Status1); return lockHolder; } catch (Exception e) { throw new Exception("Failed to getlock", e); } } public void DisplayLockInfo(ObjectLockInfo[] lockInfos){ Console.Out.WriteLine(">>> Invoking 'DispplayLockInfo' on ENOVWSConcEngCpp CAA Web service proxy"); if (lockInfos == null) { throw new ApplicationException( "object lock info is null"); } // Invoke method on remote CAA Web service try { for (int i = 0; i < lockInfos.Length; i++) { Console.Out.WriteLine("--------Object Lock Infor " + (i+1) + "------:"); if (lockInfos[i].IsLocked)
Console.Out.WriteLine("Lock Status: is locked");
else
Console.Out.WriteLine("Lock Status: is not locked");
Console.Out.WriteLine("User = " + lockInfos[i].User);
Console.Out.WriteLine("Project = " + lockInfos[i].Project);
Console.Out.WriteLine("Organization = " + lockInfos[i].Organization);
Console.Out.WriteLine("-------------------------:");
}
}
catch (Exception e)
{
throw new Exception("Failed to DispplayLockInfo", e);
}
}
} |
[Top]
ENOVIA LCA V5 Object lock information can be obtained using the following method, which
is available through the generated IConcEngWS
proxy interface:
public Status TransferOwnership(SessionToken iSessionToken, |
This method accepts the following parameters:
[in] iSessionToken |
session token |
[in] iObjOwners |
array of object lock new owner infromation |
[in] iSendEmail |
flag to or not to send email |
[out] |
Status |
The following code demonstrates the use of the transferOwnership
method:
public class CAAENOVWSConcEngCppWrapper { public void TransferOwnership(ObjectLockInfo [] lockInfos){ Console.Out.WriteLine(">>> Invoking 'transferOwnership' on ENOVWSConcEngCpp CAA Web service proxy"); if (lockInfos== null) { throw new ApplicationException( "object lock info is null"); } // Create input data SessionToken token = new SessionToken(); //place holder not used // Invoke method on remote CAA Web service
try {
Status status = proxy.TransferOwnership(token, lockInfos, false);
Console.Out.WriteLine("Status: {0}", status.Status1);
} catch (Exception e) {
throw new Exception("Failed to transferownership", e);
}
}
|
[Top]
The following code depends on:
It demonstrates a sample usage scenario for the ENOVWSConcEngCpp CAA Web service:
public class CAAENOVWSConcEngCppUseCase { private string uri = null; private string credUser = null; private string credPwd = null; public CAAENOVWSConcEngCppUseCase(string uri, string credUser, string credPwd) { this.uri = uri; this.credUser = credUser; this.credPwd = credPwd; } public void RunSampleUsageScenario(string enoviaUser, String newOwnerStr) { bool success = false; Exception exception = null; enoposapplicationbinderimpl.CAAENOPosApplicationBinderImplWrapper binderWrapper = null; enoposapplicationbinderimpl.SessionToken sessionToken = null; try { // ------------------------------------------------------------ // Step 1 - Instantiate and configure the proxies // ------------------------------------------------------------ Console.Out.WriteLine("STEP 1: Instantiating and configuring CAA Web services proxies"); // Create a CookieContainer object to maintain the HTTP session state accross proxies CookieContainer container = new CookieContainer(); // Instantiate wrapper client classes int timeOut = 360000; binderWrapper = new enoposapplicationbinderimpl.CAAENOPosApplicationBinderImplWrapper(container, uri, credUser, credPwd, timeOut); enovwsprodstructcpp.CAAENOVWSProdStructCppWrapper prodStructWrapper = new enovwsprodstructcpp.CAAENOVWSProdStructCppWrapper(container, uri, credUser, credPwd, timeOut); enovwscntmgmtcpp.CAAENOVWSCntMgmtCppWrapper cntMgmtWrapper = new enovwscntmgmtcpp.CAAENOVWSCntMgmtCppWrapper(container, uri, credUser, credPwd, timeOut); enovwsconcengcpp.CAAENOVWSConcEngCppWrapper concEngWrapper = new enovwsconcengcpp.CAAENOVWSConcEngCppWrapper(container, uri, credUser, credPwd, timeOut); // ------------------------------------------------------------ // Step 2 - Open session with ENOVIA LCA V5 // ------------------------------------------------------------ Console.Out.WriteLine("--------------------------------------------------------------------------------"); Console.Out.WriteLine("STEP 2: Opening session with ENOVIA LCA V5"); Console.Out.WriteLine("--------------------------------------------------------------------------------"); // Get user contexts string[] userContexts = binderWrapper.GetUserContexts(enoviaUser); Console.Out.WriteLine("Found {0} context(s) in database", userContexts.Length); Console.Out.WriteLine("Displaying list of available contexts:"); for (int i = 0; i < userContexts.Length; i++) { Console.Out.WriteLine("Context[{0}]: {1}", i, userContexts[i]); } // Log in using the first available context if (userContexts.Length == 0) { throw new ApplicationException("No context found for the user specified"); } sessionToken = binderWrapper.Login(userContexts[0]); // ------------------------------------------------------------ // Step 3 - Create 2 documents // ------------------------------------------------------------ Console.Out.WriteLine("--------------------------------------------------------------------------------"); Console.Out.WriteLine("STEP 3: Creating 2 documents"); Console.Out.WriteLine("--------------------------------------------------------------------------------"); string docId1 = "CAAWSCnt1" + Environment.TickCount; // the VID has to be unique string docName1 = "Doc1" + docId1; string domain = "DOCDIR"; enovwscntmgmtcpp.ENOVIA createDocResultSet1 = cntMgmtWrapper.CreateDocument(docId1, docName1, domain); string[] docUUIDs1 = cntMgmtWrapper.GetENOVIA_VPMDocumentRevisionUUIDs(createDocResultSet1); if (docUUIDs1.Length > 1) { throw new ApplicationException("Invalid state: more than 1 document was returned"); } else if (docUUIDs1.Length != 1) { throw new ApplicationException("Failed to create the document"); } string docUUID1 = docUUIDs1[0]; CAAENOVWSUtils.DisplayResults(createDocResultSet1, 1); string docId2 = "CAAWSCnt2" + Environment.TickCount; string docName2 = "Doc2" + docId2; enovwscntmgmtcpp.ENOVIA createDocResultSet2 = cntMgmtWrapper.CreateDocument(docId2, docName2, domain); string[] docUUIDs2 = cntMgmtWrapper.GetENOVIA_VPMDocumentRevisionUUIDs(createDocResultSet2); if (docUUIDs2.Length > 1) { throw new ApplicationException("Invalid state: more than 1 document was returned"); } else if (docUUIDs2.Length != 1) { throw new ApplicationException("Failed to create the document"); } string docUUID2 = docUUIDs2[0]; CAAENOVWSUtils.DisplayResults(createDocResultSet2, 1); // ------------------------------------------------------------ // Step 4 - Create part // ------------------------------------------------------------ Console.Out.WriteLine("--------------------------------------------------------------------------------"); Console.Out.WriteLine("STEP 4: Creating part reference"); Console.Out.WriteLine("--------------------------------------------------------------------------------"); string partNumber = "CAAWSCntPrt" + Environment.TickCount; enovwsprodstructcpp.ENOVIA createPartResultSet = prodStructWrapper.CreatePartRef(new string[] { partNumber }, "PRODUCT", "FALSE"); string[] partRefUUIDs = prodStructWrapper.GetENOVIA_VPMPartVersionUUIDs(createPartResultSet); if (partRefUUIDs.Length > 1) { throw new ApplicationException("Invalid state: more than 1 part reference was returned"); } else if (partRefUUIDs.Length != 1) { throw new ApplicationException("Failed to create part reference"); } string partRefUUID = partRefUUIDs[0]; CAAENOVWSUtils.DisplayResults(createPartResultSet, 1); // ------------------------------------------------------------ // Step 5 - Attach document to part // ------------------------------------------------------------ Console.Out.WriteLine("--------------------------------------------------------------------------------"); Console.Out.WriteLine("STEP 5: Attaching document to part"); Console.Out.WriteLine("--------------------------------------------------------------------------------"); string attachType = "Primary"; // "Primary" or "Secondary" string role = "Documentation"; // "Representation" or "Documentation" string[] docUUIDs = { docUUID1, docUUID2 }; cntMgmtWrapper.AttachDocument(partRefUUID, docUUIDs, attachType, role); // ------------------------------------------------------------ // Step 6 - Check in document // ------------------------------------------------------------ Console.Out.WriteLine("--------------------------------------------------------------------------------"); Console.Out.WriteLine("STEP 6: Check in document"); Console.Out.WriteLine("--------------------------------------------------------------------------------"); string fileName = "CAAFileTestForCntCheckIn.txt"; string vaultName = ""; string fileContent = "asasasasasaasasasasaskljadlkfhslkdfhsdlfhklsdh;asdhjl;dfhsdhjksdfhkshjkshjksdhfjksdhfjksd"; byte[] data = (new UnicodeEncoding()).GetBytes(fileContent); enovwscntmgmtcpp.ENOVIA checkInResultSet = cntMgmtWrapper.CkeckIn(docUUID1, fileName, vaultName, data); CAAENOVWSUtils.DisplayResults(checkInResultSet, 1); // ------------------------------------------------------------ // Step 7 - lock document 2 // ------------------------------------------------------------ Console.Out.WriteLine("--------------------------------------------------------------------------------"); Console.Out.WriteLine("STEP 7: lock document2 "); Console.Out.WriteLine("--------------------------------------------------------------------------------"); String[] docIDs = { docUUID2 }; concEngWrapper.Lock(docIDs); // ------------------------------------------------------------ // Step 8 - getLock of doc1, doc2 (locked) and partRef // ------------------------------------------------------------ Console.Out.WriteLine("--------------------------------------------------------------------------------"); Console.Out.WriteLine("Step 8 - getLock of doc1, doc2 (locked) and partRef "); Console.Out.WriteLine("--------------------------------------------------------------------------------"); String[] objIDs = { docUUID1, docUUID2, partRefUUID}; enovwsconcengcpp.ObjectLockInfo [] lockInfos = concEngWrapper.GetLock(objIDs); concEngWrapper.DisplayLockInfo(lockInfos); // ------------------------------------------------------------ // Step 9 - transfer doc1 and partRef ownership // ------------------------------------------------------------ Console.Out.WriteLine("--------------------------------------------------------------------------------"); Console.Out.WriteLine("Step 9 - transfer doc1 and partRef ownership "); Console.Out.WriteLine("--------------------------------------------------------------------------------"); String[] tokens = newOwnerStr.Split('.'); String user = tokens[0]; String org = tokens[1]; String proj = tokens[2]; Console.Out.WriteLine("user="+user+" org="+org+" proj="+proj); enovwsconcengcpp.ObjectLockInfo doclock1 = new enovwsconcengcpp.ObjectLockInfo(); doclock1.ObjID = concEngWrapper.ToIdentifier(docUUID1); doclock1.User=user; doclock1.Project=proj; doclock1.Organization=org; enovwsconcengcpp.ObjectLockInfo partLock2 = new enovwsconcengcpp.ObjectLockInfo(); partLock2.ObjID = concEngWrapper.ToIdentifier(partRefUUID); partLock2.User=user; partLock2.Project=proj; partLock2.Organization=org; enovwsconcengcpp.ObjectLockInfo [] newlockInfo = {doclock1, partLock2}; concEngWrapper.TransferOwnership(newlockInfo); // ------------------------------------------------------------ // Step 10 - getLock of doc1, and partRef to show new user // ------------------------------------------------------------ Console.Out.WriteLine("--------------------------------------------------------------------------------"); Console.Out.WriteLine("Step 10 - getLock of doc1, and partRef to see new owner"); Console.Out.WriteLine("--------------------------------------------------------------------------------"); String[] newObjIDs = { docUUID1, partRefUUID}; enovwsconcengcpp.ObjectLockInfo [] lockInfos2 = concEngWrapper.GetLock(newObjIDs); concEngWrapper.DisplayLockInfo(lockInfos2); // ------------------------------------------------------------ // Step 11 - unlock doc2 // ------------------------------------------------------------ Console.Out.WriteLine("--------------------------------------------------------------------------------"); Console.Out.WriteLine("Step 11 - unlock doc2"); Console.Out.WriteLine("--------------------------------------------------------------------------------"); String[] docIDs2 = { docUUID2 }; concEngWrapper.Unlock(docIDs2); success = true; } catch (Exception e) { exception = e; } finally { // ------------------------------------------------------------ // Step 12 - Terminate opened session // ------------------------------------------------------------ Console.Out.WriteLine("--------------------------------------------------------------------------------"); Console.Out.WriteLine("STEP 12: Terminating opened session with ENOVIA LCA V5"); Console.Out.WriteLine("--------------------------------------------------------------------------------"); // The session must be closed even if a call to a method on the ENOVWSQueryCpp // CAA Web service fails binderWrapper.Logout(sessionToken); } if (success) { Console.Out.WriteLine("================================================================================"); Console.Out.WriteLine("Use case execution successful"); Console.Out.Flush(); Console.Out.Close(); Environment.Exit(0); } else { Console.Out.Flush(); Console.Out.Close(); Console.Error.WriteLine("================================================================================"); Console.Error.WriteLine("Use case execution failed"); Console.Error.WriteLine(exception.Message); Console.Error.WriteLine("Details:"); if (exception.InnerException != null) { Console.Error.WriteLine(exception.InnerException); // handles ApplicationException launched from the use case } else { Console.Error.WriteLine(exception); // handles unexpected exception } Console.Error.Flush(); Console.Error.Close(); Environment.Exit(-1); } } } |
[Top]
This use case explains how to use the C# client binding generated using the wsdl.exe utility in order to consume the ENOVWSConcEngCpp CAA Web service. It also gives an overview of the available method:
Lock
: lock ENOVIA objects.Unlock
: unlock ENOVIA
objects.GetLock
: get lock information of
objects.TransferOwnership
: transfer
ownership of objects.[Top]
Version: 1 [Dec 2006] | Document created |
[Top] |
Copyright © 2006, Dassault Systèmes. All rights reserved.