I've been working on a wrapper for an API that will let me access it via a web service. The wrapper is a WCF service that I'm using to interface between the API and an asmx.
API---WCF---Webservice
Currently, I can get the API to work with the wrapper and the wrapper to communicate with the web service. However, any calls I make that originate from the web service to the API fail. The line that causes the failure is one that accesses a registry key on the host. My guess is that this is somehow permission related, but I'm new to C# and web services so I don't know for sure. If it is permission related, where/how can I give the client permission to access the host's registry?
WFC code:
public class IRClass
{
...
public string init()
{
string result = "THE SERVICE IS WORKING BORK BORK\n";
int handle = 1234;
double retVal = -1;
Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Rand McNally\DispatchAssistant\StandAlone\Install");
\\^^^ THIS RETURNS NULL WHEN CALLED BY A CLIENT ^^^
if (key != null)
{
string sbDARouterFilePath = key.GetValue("DaRouterPath").ToString();
string sbDADataFilePath = key.GetValue("DaDataPath").ToString();
string sbRouterFilePath = key.GetValue("RoutePath").ToString();
string sbMapFilePath = key.GetValue("MapPath").ToString();
string sbAdminFilePath = key.GetValue("AdminPath").ToString();
string sbDataFilePath = key.GetValue("DataPath").ToString();
try
{
RECode = irLib.irSAInitialize(sbDARouterFilePath, sbDADataFilePath, sbRouterFilePath, sbMapFilePath, sbAdminFilePath, sbDataFilePath);
}
catch (Exception e)
{
throw new Exception("irSAInitialize call failed in IntelliRouteLib.IRApi\n + e.Message);
}
result += "Key: " + key.ToString() + " \n";
}
else
{
result += "KEY IS NULL\n"; \\THIS SHOULDN'T HAPPEN
}
...
return result;//return RECode.ToString();
}
}
WCF App.Config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" />
</system.web>
<system.serviceModel>
<services>
<service name="RmWcfServiceLibrary.RMService">
<host>
<baseAddresses>
<add baseAddress = "http://localhost:8733/Design_Time_Addresses/RmWcfServiceLibrary/RMService/" />
</baseAddresses>
</host>
<!-- Service Endpoints -->
<endpoint address="" binding="basicHttpBinding" contract="RmWcfServiceLibrary.IIntRoute">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<!-- Metadata Endpoints -->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<system.diagnostics>
<trace autoflush="true" />
<sources>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing"
propagateActivity="true">
<listeners>
<add name="sdt"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData= "SdrConfigExample.e2e" />
</listeners>
</source>
</sources>
</system.diagnostics>
</configuration>
WebService Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using RMWebService.RmWcf;
namespace RMWebService
{
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class WebService1 : System.Web.Services.WebService
{
[WebMethod]
public string Intelliroute()
{
IntRouteClient client = new IntRouteClient();
string output = client.IRinit();
client.Close();
return output;
}
}
}
Thanks