Bentley Web Services Gateway with eB example

I couldn't find an example of how to create a document with all Its attributes, relationships and files in eB by consuming the WSG web services.

Do you have any test application example with code to work with the WSG and eB?

And one more question: all the task that can be done by consuming the old .asmx eB web service can be done by consuming the new JSON WSG web services?

Thanks a lot for your help, kind regards,
Sebastian.

  • Hi Sebastian,

    Have you tried the Development guide, as it discussed each URL in details including code samples?
    As Guide differs on API version, on which version of WSG you are and looking for?
    Are you using Standalone or with Mobile app?

    Regards,
    Manav B.



  • Hi Manav!

    Thanks for your reply.

    Yes, we have tried with the DeveloperGuide WSG Web API 2.1 . The main problem with the guide is that all examples are made for ProjectWise Connector and not for eB Connector. The second problem is that code examples are very incomplete.

    Mobile App is off the table by now. WSG would be used as a classic Web API interfase/endpoint from another customer's system (BPM).

    The initiative is to use the new WSG Web API instead of the old WebProxy.asmx Web Service but we have a serious doubt: It is possible to perform all the operations to fully complete the information of a document?

    We need to:

    -Create documents using 20 different Templates depending on document class

    -Document's indexation consist of system attributes, user defined attributes, responsibilities, relationships with other objects like projects, superseeding and files

    -The idea is to address a PostDocumentWithFileInOneRequest() described on page 38 of the development guide but with this key characteristics and with eB. Also we need to address a two phase creation operation like PostDocument() and then UploadFile().

    In all cases by PostDocument I mean post all the required information to complete the document indexation in one request.

    You know that with WebProxy.asmx if you want to create a document you need to login, keep the session and post many, many requests just to create the document using a Template and then add all the metadata to It. It's just a wrapper of the classic eB Proxy API.

    So the main question by now would be: It is possible to address this functionality with WSG? In that case: Is there any way to get examples for eB?

    Thanks a lot,
    Sebastian.
  • As mobile apps are not in the plan, I would recommend using our latest Early Adopters Preview version (02.00.04.43) that comes with 2.4 API and multiple improvements/features to eB plugin. T download the same, I would request you to please contact your account manager (Bentley) to deliver the same.

    WSG 02.00.04.43 also comes with updated developer guide in HTML format that can be found in each deployment (just go to localhost/ws)

    Even if deployment guide examples use PW schema, those are still valid for other plugins too:

    - All requests are the same for all the plugins. The names used in URLs and JSON, like class names, property names, relationships are defined in schema(s) and can be different, but request format is identical.

    - Each plugin (and actually each connection) can have multiple different schemas so you need to use meta schema urls to check what schemas, classes, properties and relationships are available in your repository (deployment guide has examples for that too). You can download whole schema in EC XML format and browse it locally if needed.

    - If I understood the feature list correctly:

    • Creating document from template – supported
    • Querying (presuming indexing means query) documents, including properties, custom properties, related objects – supported
    • I am not sure what “superseding” refers to.
    • Creating files for documents – as eB document can have multiple files, file is modelled as linked object to the document, so if you want to create new document and add new file, this will take 2 requests.

    As I mentioned above requests are the same for any plugins, but in any case – please find few document and file creation examples below.


    Document creation sample when template name was specified on deployment:

    Method POST:
    https://[machineName]/ws/v2.4/Repositories/Bentley.eB--viltest2-51.bentley.com~2CeB16.4_wsg/eB/Document

    Headers:
    Authorization: Basic YWRtaW46YWRtaW4=
    Content-Type: application/json

    Request body:
    {
    "instance":
      {
       "className": "Document",
        "schemaName": "eB",
        "properties": {
    "Name":"DocumentName1"
        },

        "relationshipInstances": [
             {
                 "className": "FolderDocument",
                 "schemaName": "eB",
                 "direction": "backward",
                 "relatedInstance": {
                     "instanceId": "14",
                     "className": "Folder",
                     "schemaName": "eB"
                 }
             }
          ]
       }
    }

    You can create a Document without specifying template Name while deploying, however you must specify Template Id property on request body.


    Method POST:
    https:// [machineName]/ws/v2.4/Repositories/Bentley.eB--viltest2-51.bentley.com~2CeB16.4_wsg/eB/File

    Headers:
    Content-Type: multipart/form-data; boundary=-------------------------acebdf13572468
    Authorization: Basic YWRtaW46YWRtaW4=

    Request body:
    ---------------------------acebdf13572468
    Content-Disposition: form-data; name="fieldNameHere"
    Content-Type: application/json

    {
      "instance": {
        "schemaName": "eB",
        "className": "File",
        "changeState": "new",
        "properties": {
          "Name": "Test.txt",
        },
                                  "relationshipInstances" : [{
                                                 "className" : "DocumentFiles",
                                                 "direction" : "backward",
                                                 "properties" : {},
                                                 "relatedInstance" : {
                                                                "className" : "Global_Document_DOC1",
                                                                "instanceId" : "15",
                                                                "schemaName" : "EB_ECPLUGIN_SCHEMA",
                                                 },
                                                 "schemaName" : "eB"
                                  }],
      }
    }
    ---------------------------acebdf13572468
    Content-Disposition: form-data; name="fieldNameHere"; filename="Test.txt"
    Content-Type: text/plain

    aaa
    ---------------------------acebdf13572468—

    Regards,
    Manav B.



    Answer Verified By: Sebastian Fernandez Pacheco 

  • Manav,

    Thanks a lot, I think this is what we need. We'll contact our Account Manager to get WSG v02.00.04.43. My last question about this subject: What eB version are supported by WSG v02.00.04.43?

    Kind regards,
    Sebastian.
  • All the versions from 15.6.1 till the latest 16.4.2.
    If you want to upgrade, we would recommend to go for 16.4.2.

    Regards,
    Manav B.



    Answer Verified By: Sebastian Fernandez Pacheco