Access 3rd web services from c++ MFC

Hi,

I need to access our developed web services from PW explorer.

I took example project from SDK library -  docprop. I would like to have a possibility have a button which connect to my web services and get some information from there.

In C# i use code like this, but can't find how to make run it on C++ with MFC.

The other option is create command in C# for PW explorer, but i do not know how to this as well.

Thanks

Darius

using (var client = new HttpClient(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate }))
{
client.BaseAddress = new Uri(sDomain);
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(scheme, pass);
String sApiPath = "/master-tables";
HttpResponseMessage response = client.GetAsync(sApiPath).Result;
response.EnsureSuccessStatusCode();
string result = response.Content.ReadAsStringAsync().Result;
List<MasterTable> prTables = JsonConvert.DeserializeObject<List<MasterTable>>(result);

foreach (MasterTable t in prTables)
{
if (t.name.Contains(tablename) == true)
{
String sApiPathTr = "/master-tables/" + t.masterTableId + "/records";
HttpResponseMessage responseTr = client.GetAsync(sApiPathTr).Result;
responseTr.EnsureSuccessStatusCode();
string resultTr = responseTr.Content.ReadAsStringAsync().Result;
ReadMasterTableFromCodes = JsonConvert.DeserializeObject<List<TableRecord>>(resultTr);
break;
}
}
}

Parents Reply Children
  • I think you probably have to define your static method as public, but the problem reported appears to be in your post build commands.  Perhaps using 'move' is the problem?  FWIW, I always copy the modified DLL file, typically with something like this:

    echo "Executing DllExporterNet4.exe $(TargetFileName)..."
    DllExporterNet4.exe $(TargetFileName)
    
    echo "copy $(TargetName).Exports$(TargetExt) $(TargetFileName)..."
    copy $(TargetName).Exports$(TargetExt) $(TargetFileName)
    
    echo "copy $(TargetFileName) "$(PWBIN)"..."
    copy $(TargetFileName) "$(PWBIN)"

    Now depending upon how you have coded all of this, you might have to load your DLL yourself before attempting to call your exported function.

    Also, you should be using the x86 version of DllExporterNet4 since this is for ProjectWise Explorer, which is an x86 application.