在ServiceModel客户端配置部分找不到引用contract.in的默认端点元素

sac*_*rni 2 c# web-services

我添加了一个名为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);
Run Code Online (Sandbox Code Playgroud)

我得到了上面提到的错误.但是,如果我在示例应用程序中测试它运行完美.

任何帮助.

Tom*_*ski 6

您好像没有复制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>
Run Code Online (Sandbox Code Playgroud)

注意:这只是一个示例文件.你需要从你的项目中找到这样的东西(在控制台中)并将该条目复制到你正在使用该服务的任何其他项目中的app.config.