0

I really need help here. I'm trying to deploy a .NET WCF Application I have been working on for the past month for the first time.

I'm using IIS 7 as my WCF host, and working with wsHTTPBinding because I need to use Session object to store credentials. My client is a WPF App that use MVVM pattern with Caliburn.Micro.

So far, I manage (I think) to succesfully create the service on IIS. If I browse "http://localhost/Ohmio/OhmioService.svc" i see the "You create a service" message. But when I run my client and try to connect to it, my App close with an error "the application has stoped working..." bla bla bla.

This is my server Web.Config:

<?xml version="1.0"?>
<configuration>
  <appSettings/>
    <system.web>
    <compilation targetFramework="4.0"/>    
    <authentication mode="Windows"/>    
    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
  </system.web>
  <system.webServer>    
    <directoryBrowse enabled="true"/>
  </system.webServer>
  <system.serviceModel>
    <bindings>
      <wsHttpBinding>      
        <binding name="myBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">         
          <readerQuotas maxDepth="200" maxStringContentLength="8388608" maxArrayLength="16384" maxBytesPerRead="2147483647" maxNameTableCharCount="16384" />
      <security mode="None" />
      <reliableSession enabled="true" />
        </binding>
      </wsHttpBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="WcfService1.Service1Behavior" name="WcfService1.OhmioSVC">    
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="myBinding" contract="WcfService1.IOhmioSVC" >          
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="WcfService1.Service1Behavior">          
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

And this is the Client App.Config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.serviceModel>
        <bindings>
            <wsHttpBinding>
                <binding name="WSHttpBinding_IOhmioSVC" maxReceivedMessageSize="20000000"/>
        <security mode="None" />
            <reliableSession enabled="true" />
            </wsHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost/Ohmio/OhmioService.svc" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IOhmioSVC" contract="OhmioSVC.IOhmioSVC" name="WSHttpBinding_IOhmioSVC">
                <identity>
                    <dns value="localhost"/>
                </identity>
            </endpoint>
        </client>
    </system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

Of couse my application works fine on my develope machine. Please Help! I don't even know where to start looking for the cause.

Thanks!

EDIT

Ok. I put the Try catch as suggested and the error goes:

Exception: Cannot open secure cannel due to security negotiation with remote endpoint.

The inner exception:

This endpoint do not admit the action ... and only proccess WSReliableMessaging

ericpap
  • 2,917
  • 5
  • 33
  • 52
  • You need to do a try/catch around where your client tries to connect to the service, then include the exception information, including any inner exceptions, in your question. – user469104 Nov 11 '15 at 20:08
  • Thanks! see my update please! – ericpap Nov 11 '15 at 20:24
  • have you looked at http://stackoverflow.com/questions/2146189/wcf-service-securitynegotiationexception – user469104 Nov 11 '15 at 20:25
  • Yes. Found it right after edit the post. Remove the from server Web.config. Now I get only the error about WSReliableMessaging. – ericpap Nov 11 '15 at 20:30

2 Answers2

0

I believe this is a duplicate of this one:

How to configure WCF Service with wsHttpBinding hosted on IIS and consumable over Web?

But I do not have the reputation to mark it as such.

Community
  • 1
  • 1
David Pine
  • 23,787
  • 10
  • 79
  • 107
  • Thanks for the sugest. Already try what the other answer sugest. I don't think is the same problem. The post you mention it's about connecting to the web server from outside the network. I didn't get there! I'm only trying to run server and client in the same machine! – ericpap Nov 11 '15 at 20:02
0

I think the problem is something to do with reliable sessions (not 100% sure but my nerve is telling me). I found some article that might help you with regards to the implementation of reliable session.

Hope this would helped you :)

Community
  • 1
  • 1
jtabuloc
  • 2,479
  • 2
  • 17
  • 33
  • Thanks for your help. The problem is definitely ReliableSession, and the concept of "PerSession". I get rid of the error, but when i call two methods of my web service, previous values from variables are lost. I think that IIS does not recognize that the two service calls are made from same client – ericpap Nov 13 '15 at 13:53
  • The only idea that cross my mind is re-write my code to créate myself the sessions. That is, when a client call "Login" method, server creates a SessionID or AccesTicket, save it on a database and return it to client. On the next method call, the client need to specify a valid SessionID that server validate against database. If valid returns the data, else throw and exception. – ericpap Nov 13 '15 at 13:56