About Revit Server WCF remote call parameters

About Revit Server WCF remote call parameters

MafiosoXu
Explorer Explorer
949 Views
6 Replies
Message 1 of 7

About Revit Server WCF remote call parameters

MafiosoXu
Explorer
Explorer

I am a loyal user and developer of AutoDesk products. Our team is now using Revit Server to implement a collaborative product. The installation and configuration process of Revit Server is relatively easy, but the WCF service invocation provided by Revit Server, When I tried to use some of the WCF service interfaces in ModelServer, I found that many interfaces, such as GetListOfModelDataFiles, required a ServiceModelSessionToken as the first parameter. But so far, I have no idea where to get this token or how to generate it, which leads to the stagnation of our team's development work. I hope friends or staff with relevant experience can see my problem and give me a little guidance on Revit Server WCF service invocation development. Thank you very much, and I hope AutoDesk's products will get better and better!

0 Likes
950 Views
6 Replies
Replies (6)
Message 2 of 7

jeremy_tammik
Alumni
Alumni

Where does ModelServer and the WCF implementation come from? Afaik, the Revit Server API is a pure REST API and has nothing to do with WCF per se. So, I assume that you are talking about some sample implementation. Is that so?

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 7

MafiosoXu
Explorer
Explorer

I'm so sorry, maybe I don't know much about this knowledge, when I installed Revit Server on the server, in IIS Manager, I can see that there are several sites(P1), all of which have an svc file. In my project experience, svc files seem to be related to WCF. According to browsing the page of ModelService.svc, I could see the relevant prompts in the attachment diagram(P2). I tried to use svcutil.exe tool to automatically generate the cs file and config file of the agent and add them to my test client project (.NET framework  P4). The code of client test is also in the following figure, but I found that ModelServiceClient object can be created normally, and it can be opened normally. Some service requests that do not require token can also be called normally, and there are return values, such as GetCentralServerVersion service interface(P3). I think Revit Server does not provide such a way to call WCF, so that developers can directly manipulate Revit Server models, or files, because my current most urgent need is to manage Revit Server's Project folder, add folders, delete folders, and add folders. Functions such as creating central files and obtaining backup from central files by local Revit clients, but I don't know how to control Revit Server. As you said, Revit Server API is a pure REST API. Is there any relevant examples or documentation available for this Revit Server API? Thank you very much for your guidance!

P1P1P2P2P3P3P4P4

0 Likes
Message 4 of 7

jeremy_tammik
Alumni
Alumni

The only Revit Server documentation and sample code that I am aware of is included in the Revit Server SDK subdirectory of the Revit SDK:

   

/RevitSdkSamples/SDK/Revit Server SDK % ls -1
  Getting Started with Revit Server REST API.rtf
  Revit Server REST API Reference.pdf
  RevitServerViewer.zip

    

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 6 of 7

jeremy_tammik
Alumni
Alumni

Maybe first check for existing discussions on Revit Server here in the forum:

  

   

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 7 of 7

MafiosoXu
Explorer
Explorer

I always have a question. The "User-Name"."User-Machine-Name" added in request.header seems to be any value, so is this information only used for logging? If I want to control permissions, for example, only certain users can create folders, lock files, and so on, how do I control that? Is there any corresponding document for reference? Thank you very much!

 

private void button1_Click(object sender, EventArgs e)
{
  // Create request

  WebRequest request = 
    WebRequest.Create(
      "http://localhost/RevitServerAdminRESTService2021/AdminRESTService.svc/foleder1|nextFolder");
  request.Method = "PUT";
  request.ContentLength = 0;
  // Add the information the request needs

  request.Headers.Add("User-Name", Environment.UserName);
  request.Headers.Add("User-Machine-Name", Environment.MachineName);
  request.Headers.Add("Operation-GUID", Guid.NewGuid().ToString()); 
  // Read the response
  string content = "";
  using (StreamReader  sr = new StreamReader(request.GetResponse().GetResponseStream()))     
  {
    content = sr.ReadToEnd();
  }
}
0 Likes