开发者

same app.config : wcftestclient work, selfHosting doesnot

i have the same app config on both programs

A - the service itself when i run it , wcf Test Client starts.

B - A self host program using -new ServiceHost(typeof(MyService)))

here it is :

<services>
  <service name="MyNameSpace.MyService"
           behaviorConfiguration="MyService.Service1Behavior">
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:5999/MyService"/>
      </baseAddresses>
    </host>
    <endpoint
          binding="basicHttpBinding"
          contract="StorageServiceInterface.IService1"
          bindingConfiguration="MyBasicHttp开发者_开发知识库Binding"
          name="basicEndPoint">

      <identity>
        <dns value="localhost"/>
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
  </service>
</services>


<bindings>
  <basicHttpBinding>
    <binding name="MyBasicHttpBinding">
      <security mode="None">
        <transport clientCredentialType="None" />
      </security>
    </binding>
  </basicHttpBinding>
</bindings>


<behaviors>
  <serviceBehaviors>
    <behavior name="HeziService.Service1Behavior">         
      <serviceMetadata httpGetEnabled="true"/>          
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

the client Uses ClientBase<StorageServiceInterface.IService1>

Client app.config :

<system.serviceModel> 
    <client>
        <endpoint address="http://myIp/MyService"
                  binding="basicHttpBinding"
                  contract="StorageServiceInterface.IService1">                
        </endpoint>
    </client>
</system.serviceModel>

when i run the selfhost program and doing host.open()

it does open it, but when i try to call a method it tells me that :

"No connection could be made because the target machine actively refused it 10.0.0.1:5999"

ofcourse when the service run from the WCF Test Client, every thing working. how could it be ??

thanks in advance


Just guessing - how about adding an address to your server side endpoint:

<endpoint address="" .... >

Yes, the base address basically defines the whole address - but you should still add the address to your service endpoint - even if it's empty.


something strange:

regards to marc_s that ask me to write my selfhost prog code..

i was using :

private void m_startServiceToolStripMenuItem_Click(object sender, EventArgs e)  
{  
    using (Host = new ServiceHost(typeof(MyNameSpace.MyService)))  
    {  
        Host.Open();  
    }  
}  

before i've added it to the question i tried to change it without the using part :

private void m_startServiceToolStripMenuItem_Click(object sender, EventArgs e)  
{  
    Host = new ServiceHost(typeof(yNameSpace.MyService));  
    Host.Open();  
}

and now its working !!

but, somehow it worked before...
thank you all anyway :-)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜