开发者

Mysterious Problem in WCF and IIS?

Hi

I wrote WCF duplex service. This service work Fine in Visual studio but when I publish this service and put it开发者_开发问答 on IIS , Service don't answer to any Client.

All Client connect to this service Properly. Also they call Service Well and no exception occur.

Only different between with these services (IIS service and VS hosted service) is they address. For example :

* IIS service address is http://localhost/SmsService/SmsService.svc or better say is virtual path address.

* VS hosted service address is http://localhost:1408/SmsSrevice.svc. absolutely I changed Server address for client's.

Here Service/App Config's:

VS Hosted Service

<system.serviceModel>
<services>
  <service name="SmsService.Business.SmsService"
           behaviorConfiguration="ServiceBehavior">
    <endpoint address="http://localhost:1408/SmsService.svc"
              binding="wsDualHttpBinding"
              contract="SmsService.Business.ISmsService">
      <identity>
        <dns value="localhost"/>
      </identity>
    </endpoint>
    <endpoint address="mex"
              binding="mexHttpBinding"
              contract="IMetadataExchange"/>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="ServiceBehavior">
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

IIS Hosted Service

    <system.serviceModel>
<services>
  <service name="SmsService.Business.SmsService"
           behaviorConfiguration="ServiceBehavior">
    <endpoint address=""
              binding="wsDualHttpBinding"
              contract="SmsService.Business.ISmsService">
      <identity>
        <dns value="localhost"/>
      </identity>
    </endpoint>
    <endpoint address="mex"
              binding="mexHttpBinding"
              contract="IMetadataExchange"/>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="ServiceBehavior">
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

Client Config

  <system.serviceModel>
<bindings>
  <wsDualHttpBinding>
    <binding name="WSDualHttpBinding_SMSService"
             closeTimeout="00:10:00"
             clientBaseAddress="http://MyMachinName:10300/SmsClientService"
             openTimeout="00:01:00" 
             receiveTimeout="00:10:00" 
             sendTimeout="00:10:00"
             bypassProxyOnLocal="false" 
             transactionFlow="false" 
             hostNameComparisonMode="StrongWildcard"
             maxBufferPoolSize="524288" 
             maxReceivedMessageSize="65536"
             messageEncoding="Text" 
             textEncoding="utf-8" useDefaultWebProxy="true">
      <readerQuotas maxDepth="32"
                    maxStringContentLength="8192" 
                    maxArrayLength="16384"
                    maxBytesPerRead="4096" 
                    maxNameTableCharCount="16384" />
      <reliableSession ordered="true" inactivityTimeout="00:10:00" />
      <security mode="Message">
        <message clientCredentialType="Windows" 
                 negotiateServiceCredential="true"
                 algorithmSuite="Default" />
      </security>
    </binding>
  </wsDualHttpBinding>
</bindings>
<client>
  <endpoint address="http://SERVER1/SmsService/SmsService.svc" 
            binding="wsDualHttpBinding"
            bindingConfiguration="WSDualHttpBinding_SMSService" 
            contract="ServiceReference.SMSService"
            name="WSDualHttpBinding_SMSService">
    <identity>
      <dns value="localhost" />
    </identity>
  </endpoint>
</client>

Even I wrote event log in first of service method but that's don't work!

so What is Problem?

Edit 1

First thank you all

Second I think, I don't explain my question clearly. "This service work Fine in Visual studio" refer to in VS I can communicate with server via client(on the same solution in VS with service). Client can call service and also service can call client, and the work fine(any calculation, callback's, database-actions and etc)

But When I publish that service which one do itself job properly in VS, into IIS that don't work fine(even in my own computer). This mean Client can create service object and connect to that IIS Hosted Service, but when client's call service there no event(calculation, callback's, database-actions) and Service also don't call Client's.

I don't understand, If any step of my code had error's that must occur in run-time in VS. So must be something i missed like security config, client side config or something else


It could be the firewall that is blocking port 1408


First of all Duplex is bad (really bad) but I am not gonna blabber about that since you have made the decision to use it.

The main problem I can see is security. I am sure windows eventlog will tell you stories on this - just check the errors on security log. By default, IIS application pools are not allowed to communicate with other machines. You did not mention that you have specifically done anything about it so I assume it is all default. Just change the Identity of the App Pool to an admin user (al thought not recommended for production) and I think you will see your problem going away - I just guess.


OFF-TOPIC: WHY DUPLEX IS BAD

  • With server trying to establish a connection back to the client, it heavily reduces the scalability of the service. In fact if the client has a bad connection or ... server's connection could be hanging there until it times out during which time, all the resources dedicated to that call will be locked hence wasted.
  • Spec of the client machine and its connection can affect the performance of the service.
  • For server it is usually made sure that it is accessible. If client is behind a firewall or NAT, they can not contact the server. [THIS IN FACT COULD BE YOUR PROBLEM].
  • So if you open up the client for the server, it means the client could be also exposed to the whole world. Security considerations for the servers are usually good but the clients they are ignored so whole lots of things now need to be considered.
  • And there are more... but that should be enough.


can you open http://localhost:1408/SmsSrevice.svc in your browser? If not check your IIS configuration. http://msdn.microsoft.com/en-us/library/ms733766.aspx

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜