.net 无法获取函数元数据,因为没有元数据存储库
在开发SAP服务器时,我得到了以下错误+堆栈跟踪,我无法理解它,也无法找到任何为我提供有用信息的google结果: 无法获取函数元数据,因为没有元数据存储库 在我遇到的一个论坛帖子中,我读到它可能需要使用权限来做一些事情,但另一端说他给了我该测试系统的完全权限。所以这似乎不是它不起作用的原因 当另一个端点尝试发送数据并在我的一端调用服务器函数时,代码就失败了。这是我的代码: SAP服务器工厂 SAP服务器.net 无法获取函数元数据,因为没有元数据存储库,.net,visual-studio,sap,.net,Visual Studio,Sap,在开发SAP服务器时,我得到了以下错误+堆栈跟踪,我无法理解它,也无法找到任何为我提供有用信息的google结果: 无法获取函数元数据,因为没有元数据存储库 在我遇到的一个论坛帖子中,我读到它可能需要使用权限来做一些事情,但另一端说他给了我该测试系统的完全权限。所以这似乎不是它不起作用的原因 当另一个端点尝试发送数据并在我的一端调用服务器函数时,代码就失败了。这是我的代码: SAP服务器工厂 SAP服务器 public委托void RfcServerHandler(RfcServer服务器,T参
public委托void RfcServerHandler(RfcServer服务器,T参数);
公共委托void RfcServerFunctionHandler(RfcServer服务器、RfcServerContext上下文、IRfcFunction函数);
公共委托void RfcTransactionIdHandler(RfcServerContextInfo上下文,RfcTID transactionId);
公共委托T RfcTransactionIdHandler(RfcServerContextInfo上下文,RfcTID transactionId);
公共类SapServer:IDisposable,ITransactionIDHandler
{
公共RfcServer服务器{get;}
公共事件RfcServerHandler状态已更改;
公共事件RfcServerHandler应用程序错误;
公共事件RfcServerHandler错误;
公共事件RfcServerFunctionHandler FunctionCalled;
公共事件RfcTransactionIdHandler CheckTransactionId;
公共事件RfcTransactionIdHandler CommitTransactionId;
公共事件RfcTransactionIdHandler ConfirmTransactionId;
公共事件RfcTransactionIdHandler RollbackTransactionId;
公共SapServer(RfcServer服务器)
{
RfcServerDelegate.ServerCalled+=RfcServerDelegateOnServerCalled;
服务器=服务器;
Server.RfcServerStateChanged+=ServerOnRfcServerStateChanged;
Server.RfcServerApplicationError+=ServerOnRfcServerApplicationError;
Server.RfcServerError+=ServerOnRfcServerError;
Server.TransactionIDHandler=CreateDefaultTransactionHandler();
}
受保护的虚拟ITransactionIDHandler GetDefaultTransactionHandler()
{
归还这个;
}
私有ITransactionIDHandler CreateDefaultTransactionHandler()
{
返回GetDefaultTransactionHandler();
}
私有void RfcServerDelegateOnServerCalled(RfcServerContext上下文,IRfcFunction)
{
if(context.Server==Server)
FunctionCalled?.Invoke(服务器、上下文、函数);
}
私有void ServerOnRfcServerError(对象o,RfcServerErrorEventArgs args args)
{
错误?.Invoke(o作为RfcServer,args);
}
私有void ServerOnRfcServerApplicationError(对象o,RfcServerErrorEventArgs args args)
{
ApplicationError?.Invoke(o作为RfcServer,args);
}
私有void ServerOnRfcServerStateChanged(对象o,RfcServerStateChangedEventArgs args)
{
State=args.NewState;
StateChanged?.Invoke(作为RfcServer,args.NewState);
}
公共RfcServerState状态{get;set;}
private bool_firstStart=true;
公开作废开始()
{
如果(!State.In(RfcServerState.Starting,RfcServerState.Running)| | | u firstStart)
{
Server.Start();
_firstStart=false;
}
}
公共无效停止(bool abortRunningCalls)
{
如果(!State.In(RfcServerState.Stopped,RfcServerState.Stopping))
服务器关闭(中止监听呼叫);
}
公共空间处置()
{
RfcServerDelegate.ServerCalled-=RfcServerDelegateOnServerCalled;
Server.RfcServerStateChanged-=ServerOnRfcServerStateChanged;
Server.RfcServerApplicationError-=ServerOnRfcServerApplicationError;
Server.RfcServerError-=ServerOnRfcServerError;
if(Server.TransactionIDHandler是IDisposable disposableTransactionHandler&!object.ReferenceEquals(disposableTransactionHandler,this))
{
disposableTransactionHandler.Dispose();
}
Server.TransactionIDHandler=null;
}
bool ITransactionIDHandler.CheckTransactionID(RfcServerContextInfo ctx,RfcTID tid)
{
if(CheckTransactionId==null)
返回true;
foreach(CheckTransactionId.GetInvocationList()中的变量项)
{
if(项为RfcTransactionIdHandler)
{
if(!handler.Invoke(ctx,tid))
返回false;
}
}
返回true;
}
void ITransactionIDHandler.Commit(RfcServerContextInfo ctx,RfcTID tid)
{
CommitTransactionId?调用(ctx,tid);
}
void ITransactionIDHandler.Rollback(RfcServerContextInfo ctx,RfcTID tid)
{
RollbackTransactionId?.Invoke(ctx,tid);
}
void ITransactionIDHandler.ConfirmTransactionID(RfcServerContextInfo ctx,RfcTID tid)
{
ConfirmTransactionId?.Invoke(ctx,tid);
}
}
app.config
<SAP.Middleware.Connector>
<ServerSettings>
<ServerConfiguration>
<servers>
<add NAME="somename"
GWHOST="some.domain.com"
GWSERV="somepassword"
PROGRAM_ID="someprogramid"
REG_COUNT="1" />
</servers>
</ServerConfiguration>
</ServerSettings>
<ClientSettings>
<DestinationConfiguration>
<destinations>
<add NAME="SapDestination1"
SYSNR="42"
USER="someuser"
PASSWD="somepassword"
LANG="EN"
CLIENT="011"
ASHOST="somehostname" />
</destinations>
</DestinationConfiguration>
</ClientSettings>
</SAP.Middleware.Connector>
如果此错误消息给任何人敲响了警钟:请分享您对如何解决此问题的见解。问题隐藏在内部异常中-服务器条目需要“REPOSITORY\u DESTINATION”,登录详细信息不正确
public static class SapServerFactory
{
private static readonly ConcurrentDictionary<string, SapServer> Servers = new ConcurrentDictionary<string, SapServer>();
public static SapServer Create(string configurationName)
{
return Servers.GetOrAdd(configurationName.ToUpper(), CreateSapServer(configurationName));
}
private static SapServer CreateSapServer(string configurationName)
{
var server = RfcServerManager.GetServer(configurationName, new Type[] { typeof(RfcServerDelegate) });
return new SapServer(server);
}
}
// http://www.dataxstream.com/2011/08/nco-3-rfc-server-step-by-step/
public static class RfcServerDelegate
{
public static event SapServerExecutionHandler ServerCalled;
public delegate void SapServerExecutionHandler(RfcServerContext context, IRfcFunction function);
[RfcServerFunction(Default = true)]
public static void DefaultHandler(RfcServerContext context, IRfcFunction function)
{
ServerCalled?.Invoke(context, function);
}
}
public delegate void RfcServerHandler<T>(RfcServer server, T args);
public delegate void RfcServerFunctionHandler(RfcServer server, RfcServerContext context, IRfcFunction function);
public delegate void RfcTransactionIdHandler(RfcServerContextInfo context, RfcTID transactionId);
public delegate T RfcTransactionIdHandler<T>(RfcServerContextInfo context, RfcTID transactionId);
public class SapServer : IDisposable, ITransactionIDHandler
{
public RfcServer Server { get; }
public event RfcServerHandler<RfcServerState> StateChanged;
public event RfcServerHandler<RfcServerErrorEventArgs> ApplicationError;
public event RfcServerHandler<RfcServerErrorEventArgs> Error;
public event RfcServerFunctionHandler FunctionCalled;
public event RfcTransactionIdHandler<bool> CheckTransactionId;
public event RfcTransactionIdHandler CommitTransactionId;
public event RfcTransactionIdHandler ConfirmTransactionId;
public event RfcTransactionIdHandler RollbackTransactionId;
public SapServer(RfcServer server)
{
RfcServerDelegate.ServerCalled += RfcServerDelegateOnServerCalled;
Server = server;
Server.RfcServerStateChanged += ServerOnRfcServerStateChanged;
Server.RfcServerApplicationError += ServerOnRfcServerApplicationError;
Server.RfcServerError += ServerOnRfcServerError;
Server.TransactionIDHandler = CreateDefaultTransactionHandler();
}
protected virtual ITransactionIDHandler GetDefaultTransactionHandler()
{
return this;
}
private ITransactionIDHandler CreateDefaultTransactionHandler()
{
return GetDefaultTransactionHandler();
}
private void RfcServerDelegateOnServerCalled(RfcServerContext context, IRfcFunction function)
{
if(context.Server == Server)
FunctionCalled?.Invoke(Server, context, function);
}
private void ServerOnRfcServerError(object o, RfcServerErrorEventArgs args)
{
Error?.Invoke(o as RfcServer, args);
}
private void ServerOnRfcServerApplicationError(object o, RfcServerErrorEventArgs args)
{
ApplicationError?.Invoke(o as RfcServer, args);
}
private void ServerOnRfcServerStateChanged(object o, RfcServerStateChangedEventArgs args)
{
State = args.NewState;
StateChanged?.Invoke(o as RfcServer, args.NewState);
}
public RfcServerState State { get; set; }
private bool _firstStart = true;
public void Start()
{
if (!State.In(RfcServerState.Starting, RfcServerState.Running) || _firstStart)
{
Server.Start();
_firstStart = false;
}
}
public void Stop(bool abortRunningCalls)
{
if (!State.In(RfcServerState.Stopped, RfcServerState.Stopping))
Server.Shutdown(abortRunningCalls);
}
public void Dispose()
{
RfcServerDelegate.ServerCalled -= RfcServerDelegateOnServerCalled;
Server.RfcServerStateChanged -= ServerOnRfcServerStateChanged;
Server.RfcServerApplicationError -= ServerOnRfcServerApplicationError;
Server.RfcServerError -= ServerOnRfcServerError;
if(Server.TransactionIDHandler is IDisposable disposableTransactionHandler && !object.ReferenceEquals(disposableTransactionHandler, this))
{
disposableTransactionHandler.Dispose();
}
Server.TransactionIDHandler = null;
}
bool ITransactionIDHandler.CheckTransactionID(RfcServerContextInfo ctx, RfcTID tid)
{
if (CheckTransactionId == null)
return true;
foreach (var item in CheckTransactionId.GetInvocationList())
{
if (item is RfcTransactionIdHandler<bool> handler)
{
if (!handler.Invoke(ctx, tid))
return false;
}
}
return true;
}
void ITransactionIDHandler.Commit(RfcServerContextInfo ctx, RfcTID tid)
{
CommitTransactionId?.Invoke(ctx, tid);
}
void ITransactionIDHandler.Rollback(RfcServerContextInfo ctx, RfcTID tid)
{
RollbackTransactionId?.Invoke(ctx, tid);
}
void ITransactionIDHandler.ConfirmTransactionID(RfcServerContextInfo ctx, RfcTID tid)
{
ConfirmTransactionId?.Invoke(ctx, tid);
}
}
<SAP.Middleware.Connector>
<ServerSettings>
<ServerConfiguration>
<servers>
<add NAME="somename"
GWHOST="some.domain.com"
GWSERV="somepassword"
PROGRAM_ID="someprogramid"
REG_COUNT="1" />
</servers>
</ServerConfiguration>
</ServerSettings>
<ClientSettings>
<DestinationConfiguration>
<destinations>
<add NAME="SapDestination1"
SYSNR="42"
USER="someuser"
PASSWD="somepassword"
LANG="EN"
CLIENT="011"
ASHOST="somehostname" />
</destinations>
</DestinationConfiguration>
</ClientSettings>
</SAP.Middleware.Connector>