【发布时间】:2011-12-23 14:32:52
【问题描述】:
我正在尝试从我制作的 dll 中调用 WCF Web 服务,该 dll 在我们的 CAD 软件中运行。 但我无法让它工作。
当我尝试建立代理时,我收到以下错误:
在 ServiceModel 客户端配置部分找不到名为“BasicHttpBinding_IAxaptaService”和合同“AxaptaProxy.IAxaptaService”的端点元素。这可能是因为找不到您的应用程序的配置文件,或者因为在客户端元素中找不到与此名称匹配的端点元素。
我搜索了一下升技,我认为问题是由于我的 DLL 在另一个程序中运行。 有一些关于将 EndPoint 配置从应用程序复制到服务的文章,但我不太明白我应该做什么。
任何人有想法,我怎样才能做到这一点?
我的客户创建的 App.Config 是这样的:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IAxaptaService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:4726/LM/AxaptaService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IAxaptaService"
contract="AxaptaProxy.IAxaptaService" name="BasicHttpBinding_IAxaptaService" />
</client>
</system.serviceModel>
</configuration>
我已尝试将其合并到我的 web.config 中,在托管 Web 服务的站点上,如下所示:
<system.serviceModel>
<bindings>
<customBinding>
<binding name="GetStream.customBinding0">
<binaryMessageEncoding/>
<httpTransport/>
</binding>
</customBinding>
<basicHttpBinding>
<binding name="BasicHttpBinding_IAxaptaService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="AutoCompletionAspNetAjaxBehavior">
<enableWebScript/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
<services>
<service name="AutoCompletion">
<endpoint address="" behaviorConfiguration="AutoCompletionAspNetAjaxBehavior" binding="webHttpBinding" contract="AutoCompletion"/>
</service>
<service name="GetStream">
<endpoint address="" binding="customBinding" bindingConfiguration="GetStream.customBinding0" contract="GetStream"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<client>
<endpoint address="http://localhost:4726/LM/AxaptaService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IAxaptaService"
contract="AxaptaProxy.IAxaptaService" name="BasicHttpBinding_IAxaptaService" />
</client>
</system.serviceModel>
里面已经有一些其他的东西了。我可以删除它们,如果这样更容易的话。我把它们留在里面,以防它们对它有一些影响。
所以我从一个独立的 winform 应用程序测试了该服务,它运行良好。 可能是因为 App.config 吗? .dll 的配置是否已加载?
【问题讨论】:
-
如果您的应用程序名为 myapp.exe,则需要将其复制到 myapp.exe.config
-
@Nicolai:基本上看起来是对的。您尝试连接的服务在哪里?同一个盒子?还是不同的盒子?如果您在复制该配置后遇到相同的错误,我会感到惊讶,并且预计您现在会遇到不同的异常 - 可能是找不到服务。
-
Merlyn:是的,现在一切都在我的本地主机上,使用 VisualStudio 的内部网络服务器。
-
我尝试创建一个 winform 应用程序,并将服务引用添加到该应用程序,并且效果很好。我猜是我的 .dll 有问题。
标签: c# wcf web-services dll