-
May 13th, 2010, 12:35 PM
#1
WCF Service desparation
Greetings, guys.
WCF services are waaay off my specialty, but I desparately need to implement one. I have turned one of my computers into web-server, I have made the WcfService project in VS 2010 and implemented everything, added the references to my main project.
Now, I have No idea how to get the service up and running on the server.
Can anyone help me with that?
Thanks
---
what i have:
the WCF project in VS on my laptop
the main project + the reference to the service
an HTTP and filesharing server with static IP
what i need:
the service to run on the server
my program to access the service from any computer
---
-
May 13th, 2010, 02:25 PM
#2
Re: WCF Service desparation
Unlike older 2.0 Web Services that needed to be hosted in IIS, WCF services can be hosted in IIS as well as other windows applications like a Window Service application, console, winforms, or WCF apps.
http://msdn.microsoft.com/en-us/library/ms730158.aspx
-
May 14th, 2010, 03:45 AM
#3
Re: WCF Service desparation
Thanks. I found that late yesterday.
What made things difficult for me, was that the WCF template in VS2010 is quite different than in VS2008. The ServiceHost was throwing an exception if I try to host the new service template in a console app. On the other hand, when I try to imlement the WCF service in the old way, with app.config and the ServiceHost that starts the service, I can't add a reference to it in other projects, because it doesn't recognize it as a service.
However, I think I found the answer. Step by step:
If you start an ordinary Console app, then
- Make a Service class
- Make an Interface
- Mark the Interface as [ServiceContract] and all methods as [OperationContract]
- Implement the Service
- Make a ServiceHost object in Program
- Add a configuration file to the project.
- Add the following XML code to app.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="MyService.Service" behaviorConfiguration="MyServiceTypeBehaviors">
<endpoint address=""
binding="wsHttpBinding"
contract="MyService.IService"/>
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/Service"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceTypeBehaviors" >
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
- Enable HTTP metadata with
<behavior name="MyServiceTypeBehaviors" >
<serviceMetadata httpGetEnabled="true" />
</behavior>
- Open the console and enable the namespace reservation with
netsh http add urlacl url=http://+:80/MyUri user=DOMAIN\user
- Open the main project, RMB ServiceReference -> Add Reference
- Enter the URL of the service, for example (http://localhost:8080/Service)
- You should see the Service listed
- Click on it, then Add and you get a new ServiceReference in your application.
- Now you can make new objects of type (YourReference.ServiceClient) and dynamically define the address in the constructor.
This did it for me, however I still have no idea how to use the new WCF template, this is all working in the VS2008 way.
-
May 14th, 2010, 07:20 AM
#4
Re: WCF Service desparation
I created a tutorial on creating and using a WCF service in a Silverlight app. Maybe it will help you out. It was done in VS2010 for Silverlight 4.
http://www.dreamincode.net/forums/to...-database-wcf/
===============================
My Blog
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|