繁体   English   中英

在ServiceModel客户端配置部分中找不到引用contract的默认终结点元素。

[英]Could not find default endpoint element that references contract.in the ServiceModel client configuration section

我添加了一个名为http://192.168.5.180:8080/intg/CrmWebService.asmx的服务引用。 名称为CrmWebProxy。

下面是代码行。

Microsoft.Crm.Accelerator.Cca.SampleServices.CrmWebService.CustomerRecord[] resultWebService = new Microsoft.Crm.Accelerator.Cca.SampleServices.CrmWebService.CustomerRecord[3];
Microsoft.Crm.Accelerator.Cca.SampleServices.CrmWebService.CRMWebServiceSoapClient client = new Microsoft.Crm.Accelerator.Cca.SampleServices.CrmWebService.CRMWebServiceSoapClient();
resultWebService = client.GetCustomerData(firstName, lastName, phoneNumber, email, accountName, accountNo, maxRecords);

我收到上面提到的错误,但是如果我在示例应用程序中对其进行测试,它将运行完美。

任何帮助。

您似乎尚未复制Web服务的配置条目。 没有它,您将无法调用Web服务。

在项目中添加服务引用时,Web服务的配置条目将添加到web.config文件的app.config中。 示例配置可能如下所示。 您需要将其复制到项目配置文件。

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="GlobalWeatherSoap" 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://www.webservicex.com/globalweather.asmx"
                binding="basicHttpBinding" bindingConfiguration="GlobalWeatherSoap"
                contract="ServiceReference1.GlobalWeatherSoap" name="GlobalWeatherSoap" />
        </client>
    </system.serviceModel>
</configuration>

注意:这只是一个示例文件。 您需要从可以在控制台中运行的项目中找到类似的内容,然后将该条目复制到正在使用该服务的任何其他项目中的app.config中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM