gpt4 book ai didi

sql - 从 C# 中的 SQL CLR 过程调用 WCF 服务

转载 作者:行者123 更新时间:2023-12-04 13:20:14 24 4
gpt4 key购买 nike

我正在尝试从用 C# 编写的 SQL 存储过程调用 WCF 服务。

我看到了关于同一主题的各种帖子或问题: Calling a WCF Service from SQL CLR Stored Procedure SQL CLR Stored Procedure and Web Service

但是有些事情我不明白。为了能够从存储过程调用我的 WCF 服务,我在过程的 C# 代码中创建了 WCF 客户端:

    //Create an endpoint addresss for our service
public static EndpointAddress endpoint =
new EndpointAddress(new Uri("http://localhost:32226/ServiceName.svc"));
//Create a binding method for our service
public static WSHttpBinding HttpBinding = new WSHttpBinding();
//Create an instance of the service proxy
public static ChannelFactory<IServiceName> MyChannelFactory = new ChannelFactory<IRecursosHumanos>(HttpBinding, endpoint);

// Create a channel.
public static IRecursosHumanos ServicioRrhh = MyChannelFactory.CreateChannel();

我正在将项目编译为 .NET 3.0+ 以便能够编译它(引用 Sytem.ServiceModel)。当我尝试在 SQL Server 上部署它时,我收到以下消息:

Msg 10301, Level 16, State 1, Line 2
Assembly 'MyAssembly' references assembly 'system.runtime.serialization, version=3.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089.', which is not present in the current database. SQL Server attempted to locate and automatically load the referenced assembly from the same location where referring assembly came from, but that operation has failed (reason: 2(failed to retrieve text for this error. Reason: 15105)). Please load the referenced assembly into the current database and retry your request.

我是否也应该在服务器上注册这个程序集?作为 WCF 所需的程序集?添加这么多程序集不会损坏服务器吗?

感谢您的帮助。

最佳答案

如果您在 CLR 程序集中使用 Web 引用而不是服务引用,它应该可以工作。

关于sql - 从 C# 中的 SQL CLR 过程调用 WCF 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3731837/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com