Reputation: 735
My simple wcf runs correctly because when I try to create an application to wcf it returns the expected data, but when I am trying to run the application outside wcf service run, it gives error
How can I fix this issue?
wcf service web config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="WcfService1.Service1">
<endpoint address="http://192.168.21.102:4424/Service1.svc"
binding="wsHttpBinding"
contract="WcfService1.IService1"></endpoint>
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"></endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
client app config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" 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://localhost:4424/Service1.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1" contract="ServiceReference1.IService1"
name="BasicHttpBinding_IService1" />
</client>
</system.serviceModel>
</configuration>
I didm\n't touch or edit those things
Upvotes: 0
Views: 1565
Reputation: 28530
Two things:
First, your service is defined to use wsHttpBinding
, but your client is using basicHttpBinding
. The bindings need to match.
Second, The address in your client config is set to localhost
- that means your client is looking for the service on the same machine the client is on.
For example, if your service is on a machine named MySever1 (for example), and you put the client (with the posted config) on a machine named MyClient1 (again, for example), it's going to look for the service on MyClient1 (localhost for the client).
Change the client endpoint to http://192.168.21.102:4424/Service1.svc
and you should be able to connect, barring any firewall issues.
For example:
<client>
<endpoint address="http://192.168.21.102:4424/Service1.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1"
contract="ServiceReference1.IService1"
name="BasicHttpBinding_IService1" />
</client>
EDIT
In your service side config, do the following for the endpoint:
service name="WcfService1.Service1">
<endpoint address=""
binding="basicHttpBinding"
contract="WcfService1.IService1">
</endpoint>
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange">
</endpoint>
</service>
In your client config:
<client>
<endpoint address="http://192.168.21.102:4424/Service1.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IService1"
contract="ServiceReference1.IService1"
name="BasicHttpBinding_IService1" />
</client>
Note that in the service endpoint declaration, the address
attribute is blank - the location of the *.svc file be used to determine the actual address. Secondly, change the binding to basicHttpBinding
to match what the client will be calling.
In the client config, specify the full address of the service you are calling.
Upvotes: 1