简体   繁体   中英

WCF Service - service in separate class library

This is my project diagram:

  • MyWCFService
    • (...)
    • web.config
  • Friends.Implementation
    • Friends.svc
      • Friends.svc.cs
  • Friends.Contract
    • IFriends.cs

My endpoint of service:

  <service behaviorConfiguration="ServiceBehaviour" name="Friends.Implementation.Friends">
    <endpoint address="" behaviorConfiguration="web" binding="webHttpBinding" contract="Friends.Contract.IFriends" />
  </service>

My question is: How can I call this service? When I had that service in "Service" folder in MyWCFService project, it was easy - just localhost:XX/Services/Friends.svc .

And now, how can I run it, if everything is in separate class libraries?

Regards

You can create a Services folder in your website root and paste the .svc file there, or you can use service activation :

<configuration>
  <system.serviceModel>
    <serviceHostingEnvironment>
      <serviceActivations>
        <add service="Friends.Implementation.Friends" 
             relativeAddress="Services/Friends.svc"/>
      </serviceActivations>
    </serviceHostingEnvironment>
  </system.serviceModel>
</configuration>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM