Jump to: navigation, search

Changes


UBIK Web Service

11,101 bytes added, 09:16, 2 August 2019
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json)]
BCMetaDefinitions GetMetaDefinitionsV212(
String appName, String contextName, String authentication, String version);
</source>
<source lang="csharp">
string appName = "APP_TEST";
string ctxName contextName = "CTX_TEST";
string authToken = FetchValidAuthToken();
string version = "263";
UBIKContentClient target = new UBIKContentClient(WEBSERVER_NAME);
BCMetaDefinitions metaDefintions = target.GetMetaDefinitionsV212(
appName, ctxName contextName, authToken, version);
</source>
 
 
 
== Download Content ==
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json)]
BCHierarchyDeltaShipments GetHierarchyDeltasV212(
String appName, String contextName, HierarchyDeltaArguments args, String authentication, String version);
</source>
<source lang="csharp">
string appName = "APP_TEST";
string ctxName contextName = "CTX_TEST";
string authToken = FetchValidAuthToken();
string version = "263";
UBIKContentClient target = new UBIKContentClient(WEBSERVER_NAME);
BCHierarchyDeltaShipments roots = target.GetHierarchyDeltasV212(
appName, ctxName contextName, args, authToken, version);
</source>
<source lang="csharp">
string appName = "APP_TEST";
string ctxName contextName = "CTX_TEST";
string authToken = FetchValidAuthToken();
string version = "263";
UBIKContentClient target = new UBIKContentClient(WEBSERVER_NAME);
BCHierarchyDeltaShipments roots = target.GetHierarchyDeltasV212(
appName, ctxName contextName, args, authToken, version);
</source>
<source lang="csharp">
string appName = "APP_TEST";
string ctxName contextName = "CTX_TEST";
string authToken = FetchValidAuthToken();
string version = "263";
UBIKContentClient target = new UBIKContentClient(WEBSERVER_NAME);
BCHierarchyDeltaShipments roots = target.GetHierarchyDeltasV212(
appName, ctxName contextName, args, authToken, version);</source>     == Download a Document == Method provides a stream to the document referenced by the contentId. <source lang="csharp">  /// <summary> /// Provides a stream to the document referenced by the contentId. /// </summary> /// <param name="appName">Name of the application</param> /// <param name="contextName">Name of the context</param> /// <param name="documentId">ID of the document content object</param> /// <param name="authentication">authentication (tokenid) for the user/device to access this service</param> /// <param name="version">Client Web Service Version number</param> /// <returns>A stream of the document</returns> [OperationContract] [WebInvoke(UriTemplate = "DownloadDocumentV212/{appName}/{contextName}/{documentId}/{authentication}/{version}", Method = "GET", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)] Stream DownloadDocumentV212( String appName, String contextName, String documentId, String authentication, String version); </source>  === List ofParameters ==={| class="wikitable" | width = "50%"|- ! Name!! Type !! Description|- | appName|| String || Name of the Application|- | contextName|| String || Name of the Context|- | documentId || String || ID of the document to be downloaded|- | authentication|| String || Valid auth token|- | version|| String || Indicator of the expected data format version|- |} === Code Example (c#) ===<source lang="csharp"> string appName = "APP_TEST"; string ctxName = "CTX_TEST"; string authToken = FetchValidAuthToken(); string version = "263"; Guid documentId = new Guid("61ba9775-c724-40ca-b5e1-7119ab9ab553"); string filePath = "any File Path hrere"; string fileType = "*.xml"; Stream stream = null; try { // ID of the object to be downloaded Guid documentId = new Guid("61ba9775-c724-40ca-b5e1-7119ab9ab553");  UBIKContentClient target = new UBIKContentClient(WEBSERVER_NAME); stream = target.DownloadDocumentV212( appName, ctxName, documentId.ToString(), authToken, version); streamReader = new StreamReader(stream); string downloadedContent = streamReader.ReadToEnd(); } finally { if (stream != null) stream.Close(); }</source>      == Create a single Content == Method for creating a single content object and retrieving the new object as result <source lang="csharp"> /// <summary> /// Member for creating a single content object and retrieving the new object as result /// </summary> /// <param name="appName">The name of the application</param> /// <param name="contextName">The name of the context the view hierarchy is defined in</param> /// <param name="ownerID">UID of the owner object to create the new content as child</param> /// <param name="authentication">The (valid) authentication token</param> /// <param name="dataShipment">Data container bringing all the necessary data for creating a singe content object</param> /// <param name="version">Client Web Service Version number</param> /// <returns>the new content object as BCDataShipment</returns> [OperationContract] [WebInvoke(UriTemplate = "CreateSingleContentV212/{appName}/{contextName}/{ownerID}/{authentication}/{version}", Method = "POST", RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json)] BCDataShipment CreateSingleContentV212( String appName, String contextName, String ownerID, String authentication, UbikContent dataShipment, String version); </source>  === List ofParameters ==={| class="wikitable" | width = "50%"|- ! Name!! Type !! Description|- | appName|| String || Name of the Application|- | contextName|| String || Name of the Context|- | ownerID|| String || ID of the owner object the new content is related to (as a child)|- | authentication|| String || Valid auth token|- | dataShipment|| UbikContent || Content of the new object (MetaInformation and Property - Values)|- | version|| String || Indicator of the expected data format version|- |}  === Code Example (c#) ===<source lang="csharp"> string appName = "APP_TEST"; string ctxName = "CTX_TEST"; string authToken = FetchValidAuthToken(); string version = "263"; // ID of the owner object the new content is related to (as a child) string ownerID = new Guid("533f1ca1-0ee0-424f-a115-0a09bbfaa6de").ToString();  UbikContent newContent = new UbikContent() { // reference to the MetaDefinition MetaClassID = new Guid("6b4bd904-8504-4e05-93dd-ae120d15a5be"), // new Object => create a new UID UID = Guid.NewGuid() };  newContent.PropertyValues = new UBIK.Service.PropertyValue[] { new TypePropertyValue<string>() { // value to set Value = "TESTVALUE", // reference to the MetaProperty definition MetaPropertyID = new Guid("4ec5281a-e0bd-4917-aff5-708352fc6953")},  new TypePropertyValue<int?>() { // value to set Value = int.MaxValue, // reference to the MetaProperty definition MetaPropertyID = new Guid("7c95ec83-a399-4b47-b827-6d87795a7b19")}, }; UBIKContentClient target = new UBIKContentClient(WEBSERVER_NAME); BCDataShipment result = target.CreateSingleContentV212( appName, ctxName, ownerID, authToken, newContent, version);</source>     == Update Contents == Method for updating a set of content objects and retrieving the updated objects as result <source lang="csharp">  /// <summary> /// Member for updating a set of content objects and retrieving the updated objects as result /// </summary> /// <param name="appName">The name of the application</param> /// <param name="contextName">The name of the context the view hierarchy is defined in</param> /// <param name="authentication">The (valid) authentication token</param> /// <param name="dataShipment">Data container bringing all the necessary data for updating a set of content objects</param> /// <param name="version">Client Web Service Version number</param> /// <returns>a set of updated content objects as BCDataShipments</returns> [OperationContract] [WebInvoke(UriTemplate = "UpdateContentListV212/{appName}/{contextName}/{authentication}/{version}", Method = "POST", RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json)] BCDataShipments UpdateContentListV212(string appName, string contextName, string authentication, UbikContent[] dataShipments, string version); </source>  === List ofParameters ==={| class="wikitable" | width = "50%"|- ! Name!! Type !! Description|- | appName|| String || Name of the Application|- | contextName|| String || Name of the Context|- | authentication|| String || Valid auth token|- | dataShipments|| UbikContent[] || Content objects to be updated (MetaInformation and Property - Values)|- | version|| String || Indicator of the expected data format version|- |} === Code Example (c#) ===<source lang="csharp"> string appName = "APP_TEST"; string ctxName = "CTX_TEST"; string authToken = FetchValidAuthToken(); string version = "263";   UbikContent updateContent = new UbikContent() { // reference to the MetaDefinition MetaClassID = new Guid("6b4bd904-8504-4e05-93dd-ae120d15a5be"), // update object => we must use the UID of an existing content object UID = new Guid("6b4bd904-8504-4e05-93dd-ae120d15a5be") };  updateContent.PropertyValues = new UBIK.Service.PropertyValue[] { new TypePropertyValue<string>() { // value to update Value = "TESTVALUE", // reference to the MetaProperty definition MetaPropertyID = new Guid("4ec5281a-e0bd-4917-aff5-708352fc6953")},  new TypePropertyValue<int?>() { // value to update Value = int.MaxValue, // reference to the MetaProperty definition MetaPropertyID = new Guid("7c95ec83-a399-4b47-b827-6d87795a7b19")}, }; UBIKContentClient target = new UBIKContentClient(WEBSERVER_NAME); BCDataShipment result = target.UpdateContentListV212( appName, ctxName, authToken, new UbikContent[] { updateContent }, version);</source>     == Upload Document == Method for updating a set of content objects and retrieving the updated objects as result <source lang="csharp">  /// <summary> /// Uploads a file to the Server. /// </summary> /// <param name="stream">The stream of the file.</param> /// <returns>The Content objet of the uploaded file</returns> [OperationContract] [WebInvoke(UriTemplate = "UploadFile", Method = "POST", ResponseFormat = WebMessageFormat.Json)] BCDataShipment UploadFile(Stream stream); </source>  === List ofParameters ==={| class="wikitable" | width = "50%"|- ! Name!! Type !! Description|- | appName|| String || Name of the Application (mujst be specified in the header)|- | contextName|| String || Name of the Context (mujst be specified in the header)|- | authentication|| String || Valid auth token (mujst be specified in the header)|- | fileTypeValue|| String || FileType of the uploaded file (mujst be specified in the header)|- | documentId|| String || UID of the related Content Instance (mujst be specified in the header)|- | version|| String || Indicator of the expected data format version (mujst be specified in the header)|- |} === Code Example (c#) ===<source lang="csharp"> string appName = "APP_TEST"; string ctxName = "CTX_TEST"; string authToken = FetchValidAuthToken(); string version = "263"; Guid documentId = new Guid("61ba9775-c724-40ca-b5e1-7119ab9ab553"); string filePath = "any File Path hrere"; string fileType = "*.xml"; Stream stream = null; try { stream = new FileStream(filePath, FileMode.Open); using (OperationContextScope scope = new OperationContextScope(target.InnerChannel)) { HttpRequestMessageProperty headerProperty = new HttpRequestMessageProperty(); headerProperty.Headers.Add("appName", appName); headerProperty.Headers.Add("contextName", ctxName); headerProperty.Headers.Add("authentication", authToken); headerProperty.Headers.Add("documentId", documentId.ToString()); headerProperty.Headers.Add("fileType", fileType);  OperationContext.Current.OutgoingMessageProperties.Add(HttpRequestMessageProperty.Name, headerProperty); UBIKContentClient target = new UBIKContentClient(WEBSERVER_NAME); BCDataShipment result = target.UploadFile(stream); } } finally { if (stream != null) stream.Close(); }
</source>
[[Category:Server|Web Service]]
1,579
edits