I created a webservice using WCF .NET 4.0, and hosted it on IIS from our local server (when everything is ok it will be migrated to a web server). In the winform application I was able to consume the method without problems, however I'm trying to create a test environment with a different url, and I could not configure web.config / app.config correctly for this. I tried using baseAddress and two different EndPoints.
The following configuration is used: (web.config - WCF ServiceHost)
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IServiceComunicacao" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxStringContentLength="2147483647"/>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="mexBehavior" name="WsComunicacao.ServiceComunicacao">
<host>
<baseAddresses>
<add baseAddress="http://192.168.0.101/" />
</baseAddresses>
</host>
<endpoint address="ws_teste/ServiceComunicacao.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IServiceComunicacao"
contract="WsComunicacao.IServiceComunicacao" name="EndPoint_IServiceComunicacao_Teste" />
<endpoint address="ws/ServiceComunicacao.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IServiceComunicacao"
contract="WsComunicacao.IServiceComunicacao" name="EndPoint_IServiceComunicacao" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="mexBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="false"/>
</system.webServer>
(app.config - WinForm Client App)
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IServiceComunicacao" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxStringContentLength="2147483647"/>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://192.168.0.101/ws_teste/ServiceComunicacao.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IServiceComunicacao"
contract="WsComunicacao.IServiceComunicacao" name="EndPoint_IServiceComunicacao_Teste" />
<endpoint address="http://192.168.0.101/ws/ServiceComunicacao.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IServiceComunicacao"
contract="WsComunicacao.IServiceComunicacao" name="EndPoint_IServiceComunicacao" />
</client>
</system.serviceModel>
And the code used to consume the webservice:
Dim wsClient As WsComunicacao.ServiceComunicacaoClient
If Debugger.IsAttached Then
wsClient = New WsComunicacao.ServiceComunicacaoClient("EndPoint_IServiceComunicacao_Teste")
Else
wsClient = New WsComunicacao.ServiceComunicacaoClient("EndPoint_IServiceComunicacao")
End If
Dim resp As WsComunicacao.Resposta = wsClient.EnviarDados(dados)
When calling the SendData method, the error occurs:
There was no endpoint listening at http://192.168.0.101/ws_teste/ServiceComunicacao.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.