C# 在ServiceModel客户端配置部分中找不到引用contract.com的默认终结点元素
我添加了一个名为的服务引用。 名为CrmWebProxy的 下面是代码行C# 在ServiceModel客户端配置部分中找不到引用contract.com的默认终结点元素,c#,web-services,C#,Web Services,我添加了一个名为的服务引用。 名为CrmWebProxy的 下面是代码行 Microsoft.Crm.Accelerator.Cca.SampleServices.CrmWebService.CustomerRecord[] resultWebService = new Microsoft.Crm.Accelerator.Cca.SampleServices.CrmWebService.CustomerRecord[3]; Microsoft.Crm.Accelerator.Cca.Sample
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 我正在WPF应用程序中使用Web服务。嗨,Tomislav,我是WPF的新手。因此,请详细说明一下。我在控制台应用程序中测试了它。它工作得很好。谢谢。这不是特定于WPF的,而是.NET如何使用web服务。请参阅我的编辑。