2時間から解決策を探しているので、あきらめてここに投稿します。
C# 3.5 DLL を作成しました。それはとても簡単な目標です:
public static string CallWsMethodClient(string sXMLSettings, string sXMLIn)
{
try
{
WS_Generic.ServiceClient serv = new WS_Generic.ServiceClient();
return serv.CallWsMethod(sXMLSettings, sXMLIn);
}
catch (Exception e)
{
XElement xRootNode = new XElement("ALL_XML_OUT");
xRootNode.Add(new XElement("DLL_ERROR_MESS", e.GetType().Name + " - " + e.Message));
xRootNode.Add(new XElement("DLL_ERROR_STACKTRACE", e.StackTrace));
xRootNode.Add(new XElement("DLL_ERROR_INNER", e.InnerException));
return xRootNode.ToString();
}
}
Web サービス (WS_Generic.ServiceClient) へのサービス参照があります。
私の目的は、この dll をアセンブリとして SQL Server 2008R2 にインポートし、Web サービスを呼び出すために SQL からメソッドを呼び出すことです。
次のコマンドで DLL をインポートします。
create assembly [blabla]
'xxxx\blabla.dll' から、permission_set = unsafe で
次のストアドプロシージャを作成します。
create function CallWsMethodClient(@sXMLSettings nvarchar(max), @sXMLIn nvarchar(max))
returns nvarchar(max) external name blabla.[WCF_SQL.WcfClient].CallWsMethodClient
そして、ストアドプロシージャを実行すると... TADA !
<ALL_XML_OUT>
<DLL_ERROR_MESS>InvalidOperationException - Could not find default endpoint element that references contract 'WS_Generic.IService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.</DLL_ERROR_MESS>
<DLL_ERROR_STACKTRACE> at System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint serviceEndpoint, String configurationName)
at System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName, EndpointAddress address)
at System.ServiceModel.ChannelFactory`1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress)
at System.ServiceModel.ChannelFactory`1..ctor(String endpointConfigurationName)
at System.ServiceModel.EndpointTrait`1.CreateSimplexFactory()
at System.ServiceModel.EndpointTrait`1.CreateChannelFactory()
at System.ServiceModel.ClientBase`1.CreateChannelFactoryRef(EndpointTrait`1 endpointTrait)
at System.ServiceModel.ClientBase`1.InitializeChannelFactoryRef()
at System.ServiceModel.ClientBase`1..ctor()
at WCF_SQL.WS_Generic.ServiceClient..ctor()
at WCF_SQL.WcfClient.CallWsMethodClient(String sXMLSettings, String sXMLIn)</DLL_ERROR_STACKTRACE>
<DLL_ERROR_INNER />
</ALL_XML_OUT>
私はただ死にたいだけです...誰かアイデアがありますか?
もちろん、私の dll の構成ファイルは name_of_dll.dll.config です。
dll がメモリ内にある可能性があるため、エンドポイントで dll をコーディングする必要がありますか? 問題は、Web サービスの URL が変更されるたびに再コンパイルする必要があることです。
前もって感謝します