3

I'm using Visual Studio Express 2010, I've created WCF service called OperatorService.svc. Two files were added to my App_Code IOperatorService.cs and OperatorService.cs. My web.config was updated with

  <system.serviceModel>
    <services>
      <service name="OperatorService">
        <endpoint address="https://ssl.mysite.com/WCF/OperatorService"   
            binding="ws2007HttpBinding" 
            bindingConfiguration="SecurityByTransport" 
            contract="IOperatorService" />
      </service>
    </services>
    <bindings>
      <basicHttpBinding>
        <binding name="SecurityByTransport">
          <security mode="Transport">
            <transport clientCredentialType="None" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
  </system.serviceModel>

Now when i'm trying to access this service online, get an error to create EndPoint but i can't figure our how to create EndPoint especially when WCF address is SSL HTTPS: enabled website.

Can someone help meh?

eugeneK
  • 10,750
  • 19
  • 66
  • 101

2 Answers2

3

The endpoint address, if you are IIS hosting, should be either left empty or a relative address.

WCF services can have base addresses. A base address defines a core part of the address space that the service can listen on and endpoints are defined relative to that base address. If you leave the address empty then the endpoint listens on the base address.

When you are self hosting you can specify a base address in a couple of different ways: in the ServiceHost constructor or in the config file. However, if you are IIS hosting then the base address is already a given - it is the location of the .svc file

As far as HTTPS goes, if you say that you are using transport security then the base address will automatically map to HTTPS as long as that is enabled as a protocol in web application in IIS manager. However, if you are using the Visual Studio Web Development Server (aka Cassini) then that does not support SSL

Richard Blewett
  • 6,089
  • 1
  • 18
  • 23
  • So why my web.config file doesn't allow me to connect with the service? – eugeneK Jun 19 '11 at 14:05
  • One: you have fully qualified the address and as I said the address is already implicit from the host; Two: if you are not using IIS or IIS Express then SSL isn't supported as a protocol – Richard Blewett Jun 19 '11 at 14:40
  • @Richard, even with relative end point address i could not connect with service – eugeneK Jun 20 '11 at 06:17
  • From the info you have given above - and assuming you leave the address blank in the endpoint - your address would be https://ssl.mysite.com/WCF/OperatorService.svc but if your host doesn't support SSL then you still won;t be able to connect. Can you get it working without SSL just to confirm to are hitting the correct address and then worry about SSL once that part is working? – Richard Blewett Jun 20 '11 at 06:23
  • This is what we are trying to do now. Odd thing is when i leave no address it points me to https://iis9.com/WCF/OperatorService.svc – eugeneK Jun 20 '11 at 06:27
  • is the site that you have deployed on called iis9.com? – Richard Blewett Jun 20 '11 at 07:24
  • no, have no idea where this come from. I've changed WPF service location manually. – eugeneK Jun 20 '11 at 07:38
  • you've changed in manually where? If the service thinks its listening at that address its probably an idea to 1) work out why or 2) use that address to talk to the service for now. Do you control the server this is running on or are you using a hosting company? – Richard Blewett Jun 20 '11 at 07:42
  • I have full control over the service, it is hosted on our server. I don't know why address is ii9.com when i did not set any address in WCF web.config. I'm trying to access this WCF service from WPF application and this is where i get iis9.com..... stuff. So i've changed it to correct address and it worked out but still have no idea why this iis9.com was added instead of ssl.mysite.com where the WCF service is located. – eugeneK Jun 20 '11 at 07:47
  • Yes but we did a lot of work to make it work and to be honest not yet sure what web.config setting made it work but thanks anyway. – eugeneK Jun 20 '11 at 07:57
2

Launch the WCF config tool (SvcConfigEditor.exe, it is a available in the menu of Visual Studio, otherwise the path should be C:\Program Files\Microsoft SDKs\Windows\v6.0\Bin) and open your config file, it is GUI tool to help you make a correct config.

The error in the config file is an incomplete endpoint element, you need to specify some attributes on the endpoint to make it work. The easiest way is to use the config tool, but of course it can be hand written. MSDN has a reference on the syntax.

Anders Abel
  • 67,989
  • 17
  • 150
  • 217
  • I can't find my config file, where it should be located? – eugeneK Jun 19 '11 at 11:33
  • You should open your web.config with the config tool. The tool will only update the wcf-related parts of the config file. – Anders Abel Jun 19 '11 at 11:34
  • Sorry for being noob but what are my Service Type and Contract? – eugeneK Jun 19 '11 at 11:42
  • The service type is the class that implements your service methods. The contract is the interface that your service class implements. We are all noobs from the start, nothing to feel sorry for :-) – Anders Abel Jun 19 '11 at 11:45
  • How do i define it as SSL connection enabled? I use HTTP connection and then define what? – eugeneK Jun 19 '11 at 11:52
  • For SSL enabling, see: http://stackoverflow.com/questions/6261093/does-setting-security-mode-transport-automatically-make-it-secure-in-a-https-we – Anders Abel Jun 19 '11 at 11:56