[英]Could not find default endpoint element that references contract.in the ServiceModel client configuration section
I have added a service reference named http://192.168.5.180:8080/intg/CrmWebService.asmx . 我添加了一个名为http://192.168.5.180:8080/intg/CrmWebService.asmx的服务引用。 with name CrmWebProxy.
名称为CrmWebProxy。
Below are the line of code. 下面是代码行。
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);
I get the above mentioned error.But if I test it in sample application it runs perfectly. 我收到上面提到的错误,但是如果我在示例应用程序中对其进行测试,它将运行完美。
Any help. 任何帮助。
It looks like you haven't copied the configuration entry for the web service. 您似乎尚未复制Web服务的配置条目。 Without it, you cannot invoke a web service.
没有它,您将无法调用Web服务。
When you add a service reference in your project, configuration entry for your web service is added in your app.config of web.config file. 在项目中添加服务引用时,Web服务的配置条目将添加到web.config文件的app.config中。 A sample configuration may look like this.
示例配置可能如下所示。 You need to copy that to your project configuration file.
您需要将其复制到项目配置文件。
<?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>
Note: this is only a sample file. 注意:这只是一个示例文件。 You need to find something like this from your project that works (in console) and copy that entry to the app.config in whatever other project you are using the service in.
您需要从可以在控制台中运行的项目中找到类似的内容,然后将该条目复制到正在使用该服务的任何其他项目中的app.config中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.