Criei um webservice utilizando WCF .NET 4.0, e hospedei no IIS do nosso servidor local (quando tudo estiver ok será migrado para um servidor na web). Na aplicação winform consegui consumir o método sem problemas, porém estou tentando criar um ambiente teste, com uma url diferente, e não consegui configurar o web.config/app.config corretamente para isso. Tentei utilizando baseAddress e dois EndPoints distintos.
Segue abaixo a configuração utilizada: (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>
E o código utlizado para consumir o 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)
Ao chamar o método EnviarDados, ocorre o erro:
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.