找不到默认终结点元素.NET 4.0

找不到默认终结点元素.NET 4.0,.net,wcf,wcf-binding,endpoint,.net,Wcf,Wcf Binding,Endpoint,我已将代理添加到VS2010/.NET 4solution的Web服务中。我的机器是Windows7操作系统。构造客户端.NET时引发以下错误: 找不到名为“FulfillmentServicesSAP”的终结点元素,并且 合同中的“FulfimentServiceSoap.fulfimmentservicesoap” ServiceModel客户端配置部分。这可能是因为没有 找不到应用程序的配置文件,或者因为没有 在客户端中可以找到与此名称匹配的端点元素 元素 我在这里发现了一个类似于SO的问

我已将代理添加到VS2010/.NET 4solution的Web服务中。我的机器是Windows7操作系统。构造客户端.NET时引发以下错误:

找不到名为“FulfillmentServicesSAP”的终结点元素,并且 合同中的“FulfimentServiceSoap.fulfimmentservicesoap” ServiceModel客户端配置部分。这可能是因为没有 找不到应用程序的配置文件,或者因为没有 在客户端中可以找到与此名称匹配的端点元素 元素

我在这里发现了一个类似于SO的问题:

然而,通读这篇文章并尝试一些答案对我来说并不奏效。我已多次编辑app.config文件,包括:

contract=“IfImplementServicesOAP”name=“FulfillmentServicesOAP”/>

contract=“FulfimentServiceSoap.fulfimmentservicessoap”name=“fulfimmentservicessoap”/>

contract=“MYFullNamespace.FulfimentServiceSoap.fullmentservicesoap”name=“fullmentservicesoap”/>

但是,在每种情况下,当我运行web服务时,事件查看器都会显示契约“FulfimentServiceSoap.fulfimmentservicessoap”,即使我已经编辑了配置文件。我还必须做些什么来获取app.config文件中的更改,或者有人有其他想法吗

编辑-从app.config添加绑定信息

<system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="FulfilmentServicesSoap" 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/WLR3.Web.services/FulfilmentServices.asmx"
                binding="basicHttpBinding" bindingConfiguration="FulfilmentServicesSoap"
               contract="FulfimentServiceSoap.FulfilmentServicesSoap"name="FulfilmentServicesSoap" />
        </client>
    </system.serviceModel>

好吧,不管怎么说,我已经解决了这个问题——我会在这里发布,以防对其他人有所帮助。DLL是在我复制到我的应用程序/库文件夹时创建的。(我没有复制创建的app.config文件)。在创建客户机的代码中,我对绑定和端点地址详细信息进行了编码,然后将它们传递给SoapClient构造函数。因此,我的代码如下所示:

BasicHttpBinding binding = new BasicHttpBinding();
EndpointAddress remoteAddress = new EndpointAddress("http://localhost/WLR3.Web.services/FulfilmentServices.asmx");
binding.Name = "FulfilmentServicesSoap";
binding.AllowCookies = false;

FulfimentServiceSoap.FulfilmentServicesSoap fulfilmentServices = new FulfimentServiceSoap.FulfilmentServicesSoapClient(binding, remoteAddress);

如果您部署的项目不使用web.config或app.config(如Sharepoint功能),则您的代码块无法读取web或app config,并且可能发生以下异常

在调用web服务之前,您可以使用下面的代码块来操作web或应用程序配置条目

BasicHttpBinding httpBinding = new BasicHttpBinding();
httpBinding.Name = "DMS_WSSoap";
httpBinding.CloseTimeout = new TimeSpan(0, 1, 0);
httpBinding.OpenTimeout = new TimeSpan(0, 1, 0);
httpBinding.ReceiveTimeout = new TimeSpan(0, 10, 0);
httpBinding.SendTimeout = new TimeSpan(0, 1, 0);
httpBinding.AllowCookies = false;
httpBinding.BypassProxyOnLocal = false;
httpBinding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
httpBinding.MaxBufferSize = 65536;
httpBinding.MaxBufferPoolSize = 524288;
httpBinding.MaxReceivedMessageSize = 65536;
httpBinding.MessageEncoding = WSMessageEncoding.Text;
httpBinding.TextEncoding = Encoding.UTF8;
httpBinding.TransferMode = TransferMode.Buffered;
httpBinding.UseDefaultWebProxy = true;

httpBinding.ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas();
httpBinding.ReaderQuotas.MaxDepth = 32;
httpBinding.ReaderQuotas.MaxStringContentLength = 8192;
httpBinding.ReaderQuotas.MaxArrayLength = 16384;
httpBinding.ReaderQuotas.MaxBytesPerRead =  4096;
httpBinding.ReaderQuotas.MaxNameTableCharCount =16384;

httpBinding.Security.Mode = BasicHttpSecurityMode.None;
httpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
httpBinding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
httpBinding.Security.Transport.Realm = "";
httpBinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;

//The url of web services.
EndpointAddress endpoint = new EndpointAddress("http://localhost/_layouts/DMS_WS/DMS_WS.asmx");

//one of the example web service which has been referenced in visual studio IDE.
LibraryWatcherWebService.DMS_WSSoapClient lservice = new LibraryWatcherWebService.DMS_WSSoapClient( httpBinding, endpoint);

没有发布更多信息(配置),很难提供帮助。你的app.config,web.config。。。需要binding config.edited该问题以在app.config中包含绑定配置-我可以在IEOK中点击localhost上的asmx页面,包括如何创建客户端的代码。添加了创建客户端的代码。
BasicHttpBinding httpBinding = new BasicHttpBinding();
httpBinding.Name = "DMS_WSSoap";
httpBinding.CloseTimeout = new TimeSpan(0, 1, 0);
httpBinding.OpenTimeout = new TimeSpan(0, 1, 0);
httpBinding.ReceiveTimeout = new TimeSpan(0, 10, 0);
httpBinding.SendTimeout = new TimeSpan(0, 1, 0);
httpBinding.AllowCookies = false;
httpBinding.BypassProxyOnLocal = false;
httpBinding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
httpBinding.MaxBufferSize = 65536;
httpBinding.MaxBufferPoolSize = 524288;
httpBinding.MaxReceivedMessageSize = 65536;
httpBinding.MessageEncoding = WSMessageEncoding.Text;
httpBinding.TextEncoding = Encoding.UTF8;
httpBinding.TransferMode = TransferMode.Buffered;
httpBinding.UseDefaultWebProxy = true;

httpBinding.ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas();
httpBinding.ReaderQuotas.MaxDepth = 32;
httpBinding.ReaderQuotas.MaxStringContentLength = 8192;
httpBinding.ReaderQuotas.MaxArrayLength = 16384;
httpBinding.ReaderQuotas.MaxBytesPerRead =  4096;
httpBinding.ReaderQuotas.MaxNameTableCharCount =16384;

httpBinding.Security.Mode = BasicHttpSecurityMode.None;
httpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
httpBinding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
httpBinding.Security.Transport.Realm = "";
httpBinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;

//The url of web services.
EndpointAddress endpoint = new EndpointAddress("http://localhost/_layouts/DMS_WS/DMS_WS.asmx");

//one of the example web service which has been referenced in visual studio IDE.
LibraryWatcherWebService.DMS_WSSoapClient lservice = new LibraryWatcherWebService.DMS_WSSoapClient( httpBinding, endpoint);