views:

228

answers:

1

I am writing my first SVC and am missing something. It all compiles fine but the page does not seem to return anything from my service.

Service Code:

namespace RivWorks.Web.Services
{
    [ServiceContract(Namespace = "http://www.rivworks.com/ws/")]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class PlayerService
    {
        [OperationContract]
        public string Decrypt(string interactive)
        {
            return RivWorks.Security.Cryptography.Internal.Decrypt(interactive);
        }

        [OperationContract]
        public void LogEvent(Int64 HistoryRequestID, string VideoPath, string Action, string Target, string ClientDateTime, string UrlReferrer, float Offset, string TimeZone)
        {
            DateTimeOffset dt = RivWorks.DateTimeInfo.ConvertFromFlash(ClientDateTime);
            RivWorks.Membership.UserInfo userInfo = RivWorks.DateTimeInfo.GetUserInfo(dt, Offset, TimeZone, "Log Request");
            RivWorks.Data.Player.LogEvent(HistoryRequestID, VideoPath, Action, Target, userInfo, UrlReferrer);
        }
    }
}

My ASPX code:

<body>
    <form id="form1" runat="server">
        <h1>Greeting</h1>
        <div>
            <asp:Literal id="PutFrameHere" runat="server" />
        </div>
        <hr />
        <asp:ScriptManager ID="SM1" runat="server">
            <Services>
                <asp:ServiceReference Path="~/Services/PlayerService.svc" />
            </Services>
        </asp:ScriptManager>
        <script type="text/javascript">
            function OnDecrypt(result) {
                www.rivworks.com.ws.PlayerService.Decrypt($get("encryptedText").value, OnDecryptComplete, OnError, null);
            }
            function OnDecryptComplete(result) {
                alert("Complete:  " + result.toString());
            }
            function OnError(result) {
                alert("Error:  " + result.toString());
            }
        </script>
        Enter encrypted string:<input type="text" id="encryptedText" />
        <br />
        <input type="button" value="Decrypt" onclick="OnDecrypt()"? />
    </form>
</body>

When I click the button, nothing appears to happen. I would expect an error or a string in response. Using FireBug and ServiceCapture do not reveal anything. ServiceCapture does not show any requests coming out.

On a slightly different note - what would I need to do to let a Flash and/or Flex app call into the service correctly? I don't do either so am curious as to what the command should look like (to give our flash/flex developers a sample to work from.)

Any hints, tips, tricks?


Forgot to say that I was using a tutorial found at http://www.pluralsight.com/community/blogs/fritz/archive/2008/01/31/50121.aspx


From my web.config:

 <system.serviceModel>
  <behaviors>
   <endpointBehaviors>
    <behavior name="RivWorks.Web.Services.PlayerServiceAspNetAjaxBehavior">
     <enableWebScript />
    </behavior>
   </endpointBehaviors>
  </behaviors>
  <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
  <services>
   <service name="RivWorks.Web.Services.PlayerService">
    <endpoint address="" behaviorConfiguration="RivWorks.Web.Services.PlayerServiceAspNetAjaxBehavior"
     binding="webHttpBinding" contract="RivWorks.Web.Services.PlayerService" />
   </service>
  </services>
 </system.serviceModel>
</configuration>

Forgive me - I am not exactly clear on what your were looking for. I also dropped out the sections that did not change when I added WCF.


<%@ ServiceHost Language="C#" 
                Debug="true" 
                Service="RivWorks.Web.Services.PlayerService" 
                CodeBehind="PlayerService.svc.cs" %>

Not quite a match...

+1  A: 

Can you show us your service config?? What binding are you using? basicHttp, or webHttp (REST)?

By default, if you're using a SOAP service in WCF, when you navigate to the *.svc file's URL location, you don't get much - a page saying a service has been found - that's about it. That's by design.

You can enable metadata on SOAP services (based on WSDL/XSD) - but you need to explicitly do that - dosen't happen by default.

UPDATE: by "service config" I mean everything in your web.config that's inside the <system.serviceModel> section - that's the WCF section.

You're using the webHttpBinding for a REST webservice - you'll need add the "webHttp" behavior to your service behavior, I think. I'm not very familiar with REST and Ajax, so that's a bit unchartered territory for me....

  <behaviors>
   <endpointBehaviors>
    <behavior name="RivWorks.Web.Services.PlayerServiceAspNetAjaxBehavior">
     <webHttp />
     <enableWebScript />
    </behavior>
   </endpointBehaviors>
   <serviceBehaviors>
    <behavior name="AjaxRestServiceBehavior">
     <webHttp />
    </behavior>
   </serviceBehaviors>
  </behaviors>

Can you try to add the <webHttp /> to your web.config, and then reference it from your service declaration:

<service name="RivWorks.Web.Services.PlayerService" 
         behaviorConfiguration="AjaxRestServiceBehavior">
marc_s
Added web.config info to my post (above). Not sure what you mean by "service config"...
Keith Barrows
Added the service definition (above). Not quite the same... I am a little lost but think I am following along. (I dislike being a newbie sometimes - lol)
Keith Barrows
Also, it seems to render fine on Win2003/IIS6 (our dev server) but not on my local machine (Win7/IIS7). http://dev.rivworks.com/services/playerservice.svc
Keith Barrows
I've added it in like you have above and am getting a warning: Attribute 'Factory' is not a valid attribute of element 'ServiceHost'. Testing with it in a few minutes...
Keith Barrows
Hmm. More errors: http://exceptioneer.com/Share/Summary.aspx?af8da4f2-e359-4293-b66b-32dd3fe066e4
Keith Barrows
It does not seem to do anything on my local dev box (Win7/IIS7), but it does throw errors on the dev server (Win2003/IIS6)
Keith Barrows
Wondering if this is because of my ServiceContract definition. The namespace is defined as www.rivworks.com but my box is kab.rivworks.com and dev is dev.rivworks.com... "Need input..."
Keith Barrows
Stepped back, dumped everything, rewrote with JSONP and now have it working. So many moving parts!
Keith Barrows